Could not load file or assembly - Framework .NET 3.5 - c#

I'm facing a compatibility issue for .NET project.
I have 2 projects:
1st project: Libary project. Target: windows Phone 7.0 OS version
project
2nd project: Console Appplication project. Refers/use the previous
library. Target: Framework .NET 3.5
When I try to run the 2nd project, I have an exception that happens when I call a function from the 1st library:
...Could not load file or assembly 'System, Version=2.0.5.0,
Culture=neutral, PublicKeyToken=7xxxxxxxx or one of its dependencies.
The system cannot find the file specified...
If I change the target for 2nd project to Framework .NET 4.0, it works well, no more crash.
Is my error really due to the different target versions ?
How can I make the 1st project to be compatible with framework 3.5 ?

As I said, 1st project was targeting framework 3.5 .NET and 2nd project was targeting Windows Phone 7.0.
Work around: change 2nd project to target framework 3.5 .NET. (in my case, I add to create a new project in my solution, which in fact was the same as the old one but targeting framework 3.5 .NET. Same sources used.)
Kindly rough but works.

I had excactly same issue. Installing Portable Class Library helped me.
https://msdn.microsoft.com/en-us/library/gg597391.aspx
There are links to downloads for different visual studio versions.

Related

Running Awesomium on .NET 3.5

Does anybody know how I can run Awesomium.NET on .NET 3.5? Seems to only work on 4.0-4.5.1 right now.
According to this question, Awesomium 1.7 should be compatible with 3.5 by adding Awesomium.Mono to the project instead, but it seems like I'm not able to do that. When choosing 3.5 project in Visual Studio the Awesomium.Mono just disappears from the references list.
Well when I started using Awesomium web browser at version 1.7.0 the reference dll are builded using .net 4.0 version. You should try to look for an older version like 1.6.6 or 1.6.5 and check if they are builded using a older .net version. If you target your project to .net 4.0 you should not have any problem because at least windows XP with service pack 3 should have installed .net framework 4.0. But windows XP support has ended.
A quick solution (but not the best) is to target the project to the .net 4.0 and export all dll references to the build path. That should make no problems when deploying the app to your clients machine because the exe will reference to the build path.
Could you give me the reasons of why you are targeting .net 3.5 so I can understand a little more your issue with .net versions and try to think about another solution for you?

Dotnet 4.0 upgrade from 2.0

i am working on a dotnet C# web application which was initially created with VS 2003. My goal is to upgrade this application to Dotnet 4.0 without changing any functionaltiy. The solution has 9 projects (1 web + 8 Library projects). The Web project refers the 8 libraries in DLLs. To start off, I created a New project in VS2010 and added the all the Project files from the existing source code. Every time i add a project file to my solution, i was prompted with the Converison wizard and i completed the conversion wizard succesfully and now the solution works fine. After the conversion, i noticed that Except the "Web" project, other projects are converted to Dotnet 2.0 but not 4.0. My application runs without error if i run it locally using VS2010. My questions are
Why the Class libaray project did not upgrade to 4.0? Currently the
Web project is shows up as Dotnet 4.0 and Libaray projects shows up
as Dotnet 2.0.
Can i deploy the application to IIS 7.0 with the
Dotnet runtime of 4.0? Will the Dlls created in version 2.0 work if my application
uses Dotnet 4.0 runtime version?
Please help...
If your'e migrating now, why not move directly to Visual Studio 2012, instead of 2010?
Anyway, what you can do is open the project properties in each of your projects, and change the target framework to the .NET framework 4.0.
Then if you get any compilation error you can probably easily solve it individually. This should be relatively easy if your projects are not too big.
As for your specific questions:
The automatic conversion would only change the format of the solution/projects to be compatible with the new version Visual Studio. It shouldn't change the target framework but you can change that yourself.
Yes, assemblies targeting .NET 2.0 can be loaded and used from assemblies targeting .NET 4.0.
1) Upgrading the solution/projects file only upgrades it's format so you can open it in VS 2010. It will usually leave the targeted .NET setting at the previous value. These are two seperate things. The wonderful thing about VS 2010 is it let's you target whatever version of .NET you desire, so no longer do you need multiple version of VS installed to support differnt .NET versions. It didn't change the targetted .NET version because it leaves it up to you. You can change it under the project settings and recompile your library projects to regenerate the DLLs
2) You will need an application pool for .NET 4. .NET is backwards compatible in that a .NET 2.0 app can run on a machine with .net 4 installed. However, the application pool for 2.0 applications must be separate from 4.0 apps. So it's just a matter of putting the app under the right app pool.

Can't add system.media.imaging even after adding PresentationCore and WindowsBase

I've just installed C# Visual Express 2010.
The project is created under Console Application.
Any ideas? Thanks.
I'm trying to copy a range in excel and save it as a image file.
I have both PresentationCore and WindowsBase in my References.
But I'm still getting this error.
"Error 1 The type or namespace name 'Imaging' does not exist in the namespace 'System.Media' (are you missing an assembly reference?)"
Target Framwork is .NET Framework 3.5. It's still not working.
On versions of Visual Studio 2010, the default framework used for console applications is .NET Framework 4 Client Profile. The classes you're trying to use are probably not available for this version of the framework.
You need to change your project so it targets the full, .NET Framework 4 (or at least .NET Framework 3.5).
I don't have the express version installed to use as a reference but in regular versions of Visual Studio, you can do this by:
Right clicking on your project in the solution explorer and select Properties.
Under the Application tab, change the Target Framework from .NET Framework 4 Client Profile to .NET Framework 4.
Save.
You'll probably have to reopen your project so the changes could take effect. The assemblies should then be available to you.

Back port .NET 4 to 3.5 SP1 in VS2010

I wrote a simple VS2010 WPF application which targeted .NET Framework 4 Client Profile. (In fact, my app does not use any .NET 4 features, but VS2010 just by default started my project targeting .NET 4 so I didn't bother to check it)
I found all XP system and even a few Window 7 of various languages failed to start the app. I decided to back port my app to target .NET Framework 3.5 or .NET Framework 3.5 Client Profile, by changing the Target Framework in solution's properties. But the app does not compile or build with the following error on System.Xaml and Microsoft.CSharp:
Warning 1 Could not resolve assembly System.Xaml. The target framework required by this assembly (4.0) is higher than the project target framework. If this reference is required by your code, you may get compilation errors. test1
Warning 2 The primary reference "Microsoft.CSharp", which is a framework assembly, could not be resolved in the currently targeted framework. ".NETFramework,Version=v3.5". To resolve this problem, either remove the reference "Microsoft.CSharp" or retarget your application to a framework version which contains "Microsoft.CSharp". test1
Warning 3 The referenced component 'Microsoft.CSharp' could not be found.
Warning 4 The referenced component 'System.Xaml' could not be found.
Is it possible to back port (or back target) a VS2010 app to .NET 3.5? If so, how?
[EDIT]
I found there was one Control - DataGrid - that is designed to use for .NET 4. I have to install WPF Tool Kit to back port the controls to 3.5. Hope someone find this helpful.
Just remove them. Tested it and works for me. I believe those assemblies were only introduced in .NET 4. The types in System.Xaml, for example, are defined some place else in .NET 3.5 (like PresentationCore for example). See this article for more info.
Remove these references altogether. If you still need them, re-add them through the UI in Visual Studio. You should see the 3.5 versions or 2.0 versions of those assemblies. By using those older versions, your app should compile.
You have to remove those references at the references folder and readd them with the 3.5 version.

Use Microsoft Solver Foundation in C#

I'm trying to use Microsoft Solver Foundation in my C# application in VS2010 Ultimate. I've installed MSF (64 bit version) and as far as I understand I should be able to use the services after declaring:
using Microsoft.SolverFoundation;
However, I get the error "The type or namespace name 'SolverFoundation' does not exist in the namespace 'Microsoft'".
I see that there's Microsoft.Solver.Foundation.dll located in C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0
Initially I thought the 64 bit version might be the problem so I uninstalled and switched to the 32 bit version. But no success either.
How can I integrate MSF into my C# application?
I'm trying to use Microsoft Solver Foundation in my C# application in VS2010 Ultimate. I've installed MSF (64 bit version) and as far as I understand I should be able to use the services after declaring:
using Microsoft.SolverFoundation;
How can I integrate MSF into my C# application?
At no point did you mention that you added a reference to this library to your project, and the behavior you are describing is consistent with not having added a reference. Therefore, you also need to add a reference to this library to your project.
I've already tried adding the references before but it wouldn't work. Now I've noticed something in the warnings (which I probably didn't see before):
"The referenced assembly "Microsoft.Solver.Foundation, Version=3.0.1.10599, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" could not be resolved because it has a dependency on "System.Web, Version=4.0.0.0, Culture=neutral which is not in the currently targeted framework ".NETFramework,Version=v4.0,Profile=Client". Please remove references to assemblies not in the targeted framework or consider retargeting your project."
I fixed this by setting Application Properties -> Application -> Target Framework from ".Net Framework 4 Client Profile" to ".Net Framework 4".
Does "Microsoft Solver Foundation" show up when you go to Add Reference...?
If it does not perhaps you are not using the correct framework, try Project -> Properties.. -> Compile -> Advanced Compile Options... and certify you are NOT using .NET 4 Framework Client Profile (uses to be default for new projects). If it is, change it to .NET 4 Framework.
If that also fails... have you downloaded and installed the solver?
You need to add a reference to that DLL you found to your project.

Categories

Resources