Migration issue from vs2008 to vs2010 - visual-studio-2010

I have Solution in vs2008 with framework 2.0. Now I migrated solution to vs2010 .net framework 2, and it works.
Here problem occur when I changed framework from 2.0 to 4.0, after that when I run application(win-form) it throws error on resource file saying
"System.IO.FileNotFoundException: Could not load file or assembly
'SpServer.resources, Version=1.0.0.2, Culture=en-US,
PublicKeyToken=null' or one of its dependencies. The system cannot
find the file specified. File name: 'SpServer.resources,
Version=1.0.0.2, Culture=en-US, PublicKeyToken=null' --->
System.IO.FileNotFoundException: Could not load file or assembly
'...SpServer.resources.dll' or one of its dependencies. The system
cannot find the file specified.
I have not made any extra resource file, and assembly was not satellite assembly too before if there is error. Please let me know how to sort out this issue.

From MSDN:
Beginning with the .NET Framework 4, the AssemblyResolve event is raised for satellite assemblies. This change affects an event handler that was written for an earlier version of the .NET Framework, if the handler tries to resolve all assembly load requests. Event handlers that ignore assemblies they do not recognize are not affected by this change: They return null, and normal fallback mechanisms are followed.
Please also see my answer to this question.

Related

Could not load file or assembly 'System.Web.Mvc, Version=3.0.0.0

I've had a look at similar postings but haven't found one that has helped fix this issue.
Just briefly, I have an mvc3 project running on azure. A couple of days ago it lost it's reference to System.Web.MVC for some reason. So I added the reference and changed the Copy Local property to True.
It built and ran on the local emulator ok. I then published it and got the following message when visting the website.
"Could not load file or assembly 'System.Web.Mvc, Version=3.0.0.0"
It turns out I only version 3.0.0.1 and not 3.0.0.0 which is stated in my web.congig file. I've tried changing the value in web.config in both the assembly and runtime sections to 3.0.0.1 but this throws another exception in azure.(although didn't change the Public Token)
I've also tried Add Deployable Dependency but this has made no difference and I've tried downloading and adding vers 3.0.0.0 to the project but vs didn't like this dll when publishing.
I've also tried changing the property Specifc Version for the assembly to False but this hasn't worked.
So for some reason I don't have v3.0.0.0 anymore but don't know how to change my project to use v3.0.0.1 I guess.
Server Error in '/' Application.
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: Could not load file or assembly 'System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Source Error:
Line 39:
Line 40:
Line 41:
Line 42:
Line 43:
Source File: E:\sitesroot\0\web.config Line: 41
Assembly Load Trace: The following information can be helpful to determine why the assembly 'System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' could not be loaded.
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
Thank's guy's. I actually just commented out the assembly line of code for the mvc assemble and changed the runtime binding code to look for v 3.0.0.1 in web.config and this has done the trick. I'm not sure if that was the best solution but having spent over a day on it time was a big factor.
I was getting a very similar error
My solution had previously been working and nothing had changed apart from some activities using source control
I created a completely new workspace and checked out the entire source code again to the new workspace, and this fixed the issue (just doing a 'get' and a 'Get Specific Version' wasn't enough)
Looks like something had got screwed up in my workspace that prevented the compiler from finding the correct .dll. Possibly related to finding it in the GAC?
I have had this problem on and off randomly for a while and I now know why.
When you update a nuget package and the package has a web.config file as part of the nuget package, it merges the content of web.config file in the nuget package with your config file. The nuget package was a private package that I build and didn't realise this.
The web.config file in the package contained the binging redirects for MVC and this causes my config file to suddenly have duplicate entries. I initially missed it because it does all the binding redirects on one line.
Once you remove any duplicate binding redirects it fixes the problem. This question was big clue to me finding out what causes this.

PortableLibrary Could not load file or assembly

I have asp.net 4 webforms website which references PortableLibrary project. In the website I serialize classes from PortableLibrary. When I deployed the project to webserver machine with IIS6 I'm getting following error:
Could not load file or assembly 'System.Xml, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)
the portable library project references System.Xml (v4.0.31029).
When I tried to deploy clean project without references, just with simple serialization of string object, it worked fine.
A tried assemblybinding in web config but without success.
Why I'm getting this error? I have no idea from where comes the '2.0.5.0' version of system.xml.
answer from here: http://visualstudiogallery.msdn.microsoft.com/b0e0b5e9-e138-410b-ad10-00cb3caf4981
which worked for me
We'll have clearer docs around this when we release, however, you need to have Update for Microsoft .NET Framework (KB2468871)[1] installed on the web server. You will also need to remove the the binding redirect - this will actually have the reverse effect of disabling the feature. :) [1] http://www.microsoft.com/downloads/en/details.aspx?FamilyID=41bdce1f-3cb3-44bb-9b33-23a1b8c99ac3&displaylang=en

Nunit fails to start my application

Visual Studio 2010 Express C#, NUnit 2.5.8, White 0.2.0
I am trying to write some tests with the NUnit + White framework.
I can get the White demo (ListBoxExample) up and running without problems.
But when I write a simple test for my own application (.Net 4.0), I have 2 problems:
Application.Launch(""):
This statement does not complain, but does NOT launch my application at all. The path is correct because if I put an incorrect path, I get an error. With the right path there are no errors, but no application is starting.
application.GetWindow(...)
This statement causes an error:
DocBackupTestSuite.Tests.StartupTest: System.IO.FileLoadException : Could
not load file or assembly 'Bricks,
Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null' or one of its
dependencies. The located assembly's
manifest definition does not match the
assembly reference. (Exception from
HRESULT: 0x80131040)
But the Bricks.dll file IS referenced in my project...
Thank you for your help
Davy
First problem is solved.
The code did not wait long enough to leave time for the application to start.
Added a Thread.Sleep(10000) after the Application.Launch() statement, and now it starts up.
2nd problem is still pending...
Anyone?
2nd problem also solved:
A reference to Bricks.RuntimeFramework was missing.
After adding this, my test runs fine ;)
If you face this problem below when you use the UI automation library(White-project)
Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'Bricks,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=83a26c96fb92c77f' or one of its dependencies.
The system cannot find the file specified.
File name: 'Bricks, Version=1.0.0.0, Culture=neutral, PublicKeyToken=83a26c96fb92c77f'
please take the following solution:
Add Reference of the dll list as follow:
•Bricks
•Bricks.RuntimeFramework
•Castle.Core
•Castle.DynamicProxy2
•log4net
•nunit.framework
•White.NUnit
•Xstream.Core
Hope your code can be work successfully now.
Download theses stuff here
http://white-project.googlecode.com/svn/tags/0.20/lib/
Reference fromhttp://sunshinetoast.com/Default.aspx

VS2010 with .Net 2.0 WinForms app - Error on binding to generic List

I've recently converted to Visual Studio 2010 and ran the conversion on a project that worked perfectly in VS2008. Things are not so sunny in Visual Studio 2010.
This is a .Net 2.0 WinForms project that makes a lot of use of binding ListViews and Grids to Generic Lists so taking out the Generic Lists isn't feasible.
I get the following error message (anonymised for posting purposes):
Could not find a type for a name. The type name was
'System.Collections.Generic.List`1[[MyAttribute, Domain, Version=1.0.0.5,
Culture=neutral, PublicKeyToken=71c8708be064889a]], mscorlib, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089'. Line 134, position 5.
C:\Projects\MyProject\Control.resx
The problem goes away if I roll the project up to .net 4.0 but this project has to target .net 2.0 so that's not a suitable long-term solution.
Googling around finds plenty of posts from people /having/ the problem but none that I can see from people who have solved the problem so any help would be greatly appreciated.
Ta.
Delete the section in the .resx file and then also delete the line in the designer.cs (resources.GetObject("..."))that's loading that resource.
Then try opening the control in the designer and both should get regenerated, you might get a null reference exception depending on the control that's exposing a property that gets set in the designer. For me I was able to ignore and continue.
After the designer appears you can compare the resx file and see that whatever object it was is now serialized a little differently. Also if it's your custom control and you are exposing a generic list property consider putting the [Browsable(false)] attribute on it first so you cannot set the value from the designer and the designer will not automatically set it to a new value.
What was happening in my case was an empty generic list was serialized to the resx file and then after upgrading visual studio the list no longer serialized the same way.
Not much to info to go on here..
Looks like a serialization problem. Are you serializing a collection property on control? Does it need to be serialized?
If it's not needed try adding a DesignerSerializationVisibility attribute. It tries to serialize all properties by default.
We are finding this too... Our VS2008 projects that contain a property that exposes a generic list will get the same exception when building. We are using MSBuild 3.5 on a VS2010 build machine (it has 2010 installed, but we can't upgrade the projects to 2010 format yet).
Our error comes from a form:
TBDEV830.resx (143): Could not find a type for a name. The type name was 'System.Collections.ObjectModel.ObservableCollection`1[[T1.Tb.SideBar.ISideBar, T1.Tb.SideBar, Version=1.0.3702.18460, Culture=neutral, PublicKeyToken=null]], WindowsBase, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Line 143, position 5.
Have found a few posts from other forums and no-one seems to have found a solution yet:
One article states to add [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] but this has no affect.
Another article (http://www.go4answers.com/Example/tfs2008-tfs2010-migration-upgrade-3526.aspx) states to load it in the IDE and asks if that helps isolate the problem, but that would mean upgrading the project to 2010 format, which ew can't do.

WatiN Error Could not Load Assembly

I am getting the following WatiN error:
Unhandled Exception: System.IO.FileLoadException: Could not load file
or assembl y 'Interop.SHDocVw, Version=1.1.0.0, Culture=neutral,
PublicKeyToken=db7cfd3acb5 ad44e' or one of its dependencies. The
located assembly's manifest definition do es not match the assembly
reference. (Exception from HRESULT: 0x80131040) File name:
'Interop.SHDocVw, Version=1.1.0.0, Culture=neutral, PublicKeyToken=db
I copied the shDocvw.dll from System32 to the bin directory but still it is giving me the same problems.
If you've installed and referenced WatiN using NuGet in VS2010, you should already have the correct references, so they don't need to be removed and re-added. But you will still need to change the "Embed Interop Types" setting to False on the Interop.SHDocVw reference.
UPDATE: This answer was written before Nuget was released and applies only if you are NOT using Nuget to manage your dependencies. If you are using Nuget see the answer by #Nick Jones
I just had this issue today. You need to download the latest version of WatiN (I'm using 2.0.10.928) and reference the signed Interop.SHDocVw.dll that is provided by WatiN.
Try the follwoing:
Remove all other References to Interop.SHDocVw.dll
Right Click your solution and select 'Clean Solution'
Reference the Interop.SHDocVw.dll that is provided by WatiN
Build your solution.
Hope this helps.
UPDATE: Nick Jones is correct. This should not be an issue if you are using NuGet....but I was also getting this message when using MvcContrib.Mvc3.TestHelper-ci. At first glance it seems like the '-ci' packages is the way to go but I decided to use the MvcContrib.WatiN package for two reasons.
1) I don't get the "Could not load file or assembly" error message
2) The MvcContrib.Mvc3.TestHelper-ci is using an old version of WatiN.Core.dll (1.3.0.4000) where as the MvcContrib.WatiN package is using a newer version (2.0.0.99)
Check out the Properties of the Reference "Interop.SHDocVw.dll". Change the "Embed Interop Types" to False.
The problem is that it is not copying the dll file in your bin folder. But after this setting, it will do it properly.
I had the same error, and now its working fine.

Resources