WCF Test Client not working with VS 2010 on Windows 7 64 bit - wcf

I am unable to use the WCF Test Client. I always get the following error.
Error: Cannot load reference assembly 'C:\Windows\Microsoft.Net\assembly\GAC_32\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll'
Cannot load file C:\Windows\Microsoft.Net\assembly\GAC_32\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll as an Assembly. Check the FusionLogs for more Information.
Could not load file or assembly 'file:///C:\Windows\Microsoft.Net\assembly\GAC_32\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll' or one of its dependencies.
This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
I'm not having any luck finding a solution on google. I'm hoping that the stackOverflow hive brain can help.
Thanks.

If I'm not mistaken, you need to add the runtime version setting in your app.config file's <configuration> element:
<startup>
<requiredRuntime version="v4.0.30319" />
</startup>

Related

mixed mode assembly is built against version 'v2.0.50727'

I am trying to make a COM for my old project. The COM is built successfully, but when I tried to use the COM to call some functions, this error comes out:
Mixed mode assembly is built against version 'v2.0.50727' of the
runtime and cannot be loaded in the 4.0 runtime without additional
configuration information.
The old project have some parts in .NET 4.0, and some parts in .NET 3.5. Though I tried to make all parts in .NET 4.0, some third party DLLs I used cannot be rebuilt to higher framework.
I have searched this problem, and all people told me to add a app.config or web.config to the application that:
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku='.NETFramework,Version=v4.0' />
<requiredRuntime version="v4.0.30319" />
</startup>
This will work when form or server calling. But my COM may be called by vbs like:
Dim obj
Set obj = CreateObject("ClassLib.Class1")
msgbox obj.add(3,5)
In this case, I can't add that config file to the vb file. Is there any solution fot this?

Getting rid of App.exe.config

I am working on a vb.net application that uses SQLite and since it was compiled against the version 2 of the .net framework, i added this line to my config file
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
My final objective for the application is to make it a standalone, so not a single file except the exe (well the application will generate a file for the database, but my point is i want the user to only download 1 single file).
And i noticed that when i build it, the config file is always copied, and if i run the application without the config file, i would get the uncaught exception "legacy" error..
Is there any way to either include that config during runtime? or perhaps catch some type of exception to prevent that dialog from showing up and scaring the user (i know this probably not the best approach)
I have searched and found other similar problems on SO but none of the questions i found got to a solution that worked for me so i would appreciate your help.
While it is possible to set the legacy runtime policy at runtime, I would recommend deploying as an installer.
well the application will generate a file for the database, but my point is i want the user to only download 1 single file
They could download your installer, which could take care of setting up everything correctly. This is likely to be required in any case, as SQLite will need its own DLLs as well as your .exe to be there in the deployment.

How to Install NeatUpload?

Salvete! Whilst searching for a quality, free asp.net/ajax upload control, I found NeatUpload. I cannot find an online demo for it, but the download package does come with a demo. I need some help installing it on my server (Windows Server 2008).
I followed the directions at http://mumblestiltskin.blogspot.com/2009/10/using-neatupload-simple-setup.html (they are basically the same as the directions in the manual.htm that comes with the NeatUpload binary package).
So far, I have
Successfully installed Brettle.Web.NeatUpload.dll to the GAC using
gacutil.
Added the reference in my web.config (with version and guid)
copied the demo file and its code-behind to my web application (which
is registered in iis7)
Now, when I browse to the page, I get an asp.net server error on
Line 35: protected MultiFile multiFile;
Line 36: protected MultiFile multiFile2;
Line 37: protected InputFile inputFile;
and
error CS0246: The type or namespace name 'MultiFile' could not be found (are you missing a using directive or an assembly reference?)
error CS0246: The type or namespace name 'MultiFile' could not be found (are you missing a using directive or an assembly reference?)
error CS0246: The type or namespace name 'InputFile' could not be found (are you missing a using directive or an assembly reference?)
error CS0246: The type or namespace name 'InputFile' could not be found (are you missing a using directive or an assembly reference?)
error CS0246: The type or namespace name 'ProgressBar' could not be found (are you missing a using directive or an assembly reference?)
error CS0246: The type or namespace name 'ProgressBar' could not be found (are you missing a using directive or an assembly reference?)
What do I do now? Do I need to copy another dll somewhere, or certain files? I can't figure it out from the documentation.
Figured it out! I am deploying the control to a sharepoint web application. (Below, consider SPVD as "Sharepoint Application's Virtual Directory".) If you are not deploying to a Sharepoint website, then you will use the root of your web application's virtual directory where I have used Sharepoint's instead. Here are the steps I followed to get the demo page to run on my server.
Firstly, configuration is different if you use a "web-application" instead of a "web-site". I won't go into the difference here. But in my example, I am configuring a simple "web-site".
I had to:
Copy Brettle.Web.NeatUpload.dll into the GAC on the server (it seems that on Windows Server 2008, you don't have to use the gacutil - just copy the dll into %windir%\assembly. Also note that you must do this on the server; it doesn't work right if you try to do it over a network share). If you don't do this, the NeatUpload Demo just won't do anything. You will have to restart the website in IIS after you do this.
Some of the guides say you need to update the web.config to display the appropriate version and guid, but I found that I didn't have to do that (you will see my web.config below) - UNLESS - you want to use neatupload's section configuration in web.config. So, it is better just to do it right, you know.
The guides also say to use the guid and version number in the aspx pages, like demo.aspx, So, replace this:
<%# Register TagPrefix="Upload" Namespace="Brettle.Web.NeatUpload" Assembly="Brettle.Web.NeatUpload" %>
with this:
<%# Register TagPrefix="Upload" Namespace="Brettle.Web.NeatUpload" Assembly="Brettle.Web.NeatUpload, Version=1.3.3798.663,Culture=neutral, PublicKeyToken=c95290d92c5893c8" %>
Copy the entire directory at NeatUpload-1.3.25\dotnet\app\bin to SVPD\bin. It contains the following items:
Brettle.Web.NeatUpload.dll (the same as the one you installed to the GAC)
Brettle.Web.NeatUpload.GreyBoxProgressBar.dll
Brettle.Web.NeatUpload.HashedInputFile.dll
Hitone.Web.SqlServerUploader.dll
a directory called en-US (with a dll in it)
another direcotry called fr (with a dll in it)
several .mdb databases, and Brettle.Web.NeatUpload.xml
Add the references to the http modules to the web-application's web.config file (see web.config sample below).
Now, you need to copy the directory: NeatUpload-1.3.25\dotnet\app\NeatUpload to SPVD, and leave it named NeatUpload, so that you have SVPD\NeatUpload with all its original contents. Now, in that folder, there are two files you need to edit: Progress.aspx and SmoothProgress.aspx. In the guides, I was told to use the guids and version numbers in the # declarations, such as this:
<%# Page language="c#" AutoEventWireup="false" Inherits="Brettle.Web.NeatUpload.ProgressPage,Brettle.Web.NeatUpload,Version=1.3.3519.18793,Culture=neutral,PublicKeyToken=C95290D92C5893C8" %>
<%# Register TagPrefix="Upload" Namespace="Brettle.Web.NeatUpload" Assembly="Brettle.Web.NeatUpload, Version=1.3.3798.663,Culture=neutral, PublicKeyToken=c95290d92c5893c8" %>
Here is the web.config I put in the folder with the demo page.
<?xml version="1.0"?>
<configuration>
<configSections>
<!--You need this part so that you can have a neatupload configuration section. You will get .net errors if you try to add the configuration section without this part here.-->
<section name="neatUpload"
type="Brettle.Web.NeatUpload.ConfigSectionHandler, Brettle.Web.NeatUpload"
allowLocation="true"
/>
</configSections>
<!--This is where you put your neatupload configuration preferences.-->
<neatUpload xmlns="http://www.brettle.com/neatupload/config/2008"
useHttpModule="true"
/>
<system.web>
<customErrors mode="Off"/>
<!-- Always required to use any of NeatUpload's features. Without it, ProgressBars won't display and MultiFile will look like a regular HtmlInputFile. -->
<httpModules>
<add name="UploadHttpModule" type="Brettle.Web.NeatUpload.UploadHttpModule,Brettle.Web.NeatUpload,Version=1.3.3798.663,Culture=neutral,PublicKeyToken=c95290d92c5893c8" />
</httpModules>
<!-- Set these next 2 attributes large enough to accomodate the largest and longest running upload you want to support. Note that browsers and IIS typically don't support uploads larger than 2GB (2097151 KB). -->
<httpRuntime maxRequestLength="2097151" executionTimeout="999999"/>
<!-- Not required for NeatUpload but makes it easier to debug in VS. -->
<compilation debug="true"/>
</system.web>
<!-- For IIS7's Integrated Pipeline Mode which is used by the DefaultAppPool. -->
<system.webServer>
<security>
<requestFiltering>
<!-- Increased maxAllowedContentLength from default of 300MB. -->
<requestLimits maxAllowedContentLength="2147483648" />
</requestFiltering>
</security>
<modules>
<add name="UploadHttpModule" type="Brettle.Web.NeatUpload.UploadHttpModule,Brettle.Web.NeatUpload,Version=1.3.3798.663,Culture=neutral,PublicKeyToken=c95290d92c5893c8" preCondition="managedHandler"/>
</modules>
<validation validateIntegratedModeConfiguration="false"/>
</system.webServer>
</configuration>
Some Notes on Installation Packages
The installation package I used was at http://neatupload.codeplex.com/releases/view/46086 - there seem to be a few others, such as a "binaries package" at http://neatupload.codeplex.com/releases/view/59339, but the directory structure is different, and the instructions won't make much sense. There is also a package on the main project page at CodePlex: http://neatupload.codeplex.com/, but if you use this package, you will have a different version number and guid for the dll when you deploy it to the GAC.
Instruction Manuals
By way of an instruction manual, check out: http://mumblestiltskin.blogspot.com/2009/10/using-neatupload-simple-setup.html?showComment=1335835416022#c1846924755786832325, and there is also an html manual in the binaries package above. In the other packages, you have to "build" the manual with Open Office. Then, of course, you can reference this post!
Troubleshooting
Having problems?
How to Overcome this NeatUpload Object Reference Error?
NeatUpload Nabble Forum: http://neatupload-help.688956.n3.nabble.com/
The only thing left now, is to add some sort of handler for copying the files to where you want them. NeatUpload only adds them to a temp file, and I have yet to figure out where it is...

SharpSVN error in VS2010

I'm trying to get SharpSVN to work with a VB.NET project I'm working on in VS2010. I've added SharpSVN.dll to my project references but the following error appears when I try to load the site:
Could not load file or assembly 'SharpSvn' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.BadImageFormatException: Could not load file or assembly 'SharpSvn' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
My machine is 64-bit, and I've set the Configuration Manager to build to x64 as well as copied the 64-bit version of SharpSVN.dll into my project's bin directory. Additionally, I've also tried setting build to x86 and using the x86 version of SharpSVN.dll and the same error appears (so I suspect the error may not be directly related to instruction set family).
In my config file, I've tried adding the following to the assemblies attribute:
<add assembly="SharpSvn, Version=1.6016.1637.10768, Culture=neutral, PublicKeyToken=d729672594885a28"/>
Any ideas?
I have the same error and can't explain what's going on. However, with the 32bit version, the error is more descriptive:
Unhandled Exception: System.IO.FileLoadException: Mixed mode assembly is built against
version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without
additional configuration information.
Which you can fix by adding the following snippet to your app.config
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0"/>
</startup>
Not sure what's wrong with the 64bit version, but you can always build it from source.
Despite thinking that <add assembly> was enough, I actually solved this issue by adding SharpSvn to GAC (in case anybody is running into this problem as well).
I am not sure why adding to the GAC worked for you, this is not the correct behavior for the assembly loader.
The error refers to the bitness of an assembly. SharpSVN is a mixed mode assembly, ie: it contains both managed and unmanaged code. You must specifically target x86 (with the x86 SharpSVN Assembly) or x64 (again with appropriate assembly). You must further set all your assemblies to be explicitly x86 or x64. Targeting Any CPU will allow the runtime to make this decision for you, and it will fail to load SharpSvn.dll if it picks a word length that does not match the SharpSvn DLL.

Getting a "ComponentActivatorException" using Castle Windsor from a .net 4.0 application using a .net 2.0 component

I have an application which is being developed in VS2010, and makes use of the Castle-Windsor IoC, through a configuration file.
One of the components I am registering, also developed in VS2010, references a .net 2.0 component (LeadTools), so recompiling the 2.0 project isn't an option. When the wrapping component's registration is done, a "ComponentActivatorException" is raised, which wraps a "System.TypeInitializationException", which in turn wraps a "System.IO.FileLoadException" with a message of "Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information."
I have added the runtime declaration to the application's configuration file, as so:
<!-- useLegacyV2RuntimeActivationPolicy is needed for LEADTools-->
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
<supportedRuntime version="v2.0.50727" />
</startup>
This works fine if the wrapping component isn't registered in Windsor, however, it does appear to disregard the directives otherwise.
Thanks!
I assume you're using registration via XML?
What happens if you register the component in code?
Can you try to reproduce the issue without error?
call Type.GetType("assembly qualified name of the type from .net 2.0 assembly");
The problem was due to using "define"s and "if"s within the configuration file, per the MicroKernel documentation. Removing all of those elements from the App.Config file allowed the components to be instantiated, whether or not they were registered in the Windsor container.