Click here to Skip to main content
15,891,773 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created a app using csharp and vs.The project targets to 4.5.1 and it refers to mscorlib.dll assembly, but when I run the app ,The loaded mscorlib.dll version is 4.7.2 . I dont know why and how can I sepcify the right version of assembly.
In face I just want the app load the 4.5.2 version assembly like mscorlib.dll or other strong named assemblyies.
Thank you so much.

What I have tried:

I have looked up the assemblies in VS when debugging.
Posted
Updated 16-Jan-18 4:48am

You can use 'Specific Version' and 'Copy Local' on your reference node in your project to force to use a specific version of an assembly, however in this case you have to deploy that assembly with your application (maybe it is not on the target machine)...

And by the way: why?
 
Share this answer
 
Comments
codeprojectddx 16-Jan-18 11:39am    
Thank you . I wanted to debug .net 4.5.1 in vs. To keep source code and loaded dll match each other , I think load specified version dll is a good idea.
Now i have got the specified version dll ,the version is about file version . But I have no idea how to load it other than gac dll.
Since v4.0, each new version of the .NET Framework has been released as an "in-place upgrade", replacing any previous v4.x install.

Therefore, if you compile your application against v4.5, and run it on a computer with v4.7 installed, your application will be running under v4.7, and it will load the v4.7 versions of the system assemblies.

There is nothing you can do to change that, and there shouldn't be any reason for you to do so. Microsoft go to great lengths to ensure that each new version is backwards-compatible with the previous versions. In cases where the behaviour changes between versions, applications compiled against older versions typically get the older behaviour.

If you believe you have found a genuine case where your v4.5 application is broken when running under v4.7, then you'll need to report it to Microsoft.
 
Share this answer
 
Comments
codeprojectddx 16-Jan-18 11:43am    
Thanks a lot .I doubt that i have never install .net framework 4.7.2 but when running the exe , it will load the 4.7.2version dll .Why?
PS:I really hope my application well be running under v4.6 or lower.
Richard Deeming 16-Jan-18 11:47am    
If it's loading v4.7.2 system assemblies, then your computer has v4.7.2 installed. If you didn't install it, then it's probably snuck in via Windows Updates.
codeprojectddx 16-Jan-18 18:03pm    
now i am looking for a way to uninstall version 4.7.2
Richard Deeming 17-Jan-18 7:11am    
Why? If it's broken something, then you should report the bug to Microsoft. If it hasn't broken anything, then why uninstall it?
codeprojectddx 17-Jan-18 9:35am    
now i have 4.7.1 source code,i want my app which targets .net 4.7.1 to run and load the same version assembly of 4.7.1 not 4.7.2 assembly

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900