none
Problem running vb.net project compiled to .net framewok 4 RRS feed

  • Question

  • I have  .net framework 4.0.30319 installed in C:\Windows\Microsoft.NET\Framework\v4.0.30319 and .net framework 4.0 installed in  C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0 in my machine.

    I am using Visual Studio 2010.  I compiled my vb.net project with target framwork as .net Framework 4. I have no problem running the compiled project in my manchine. But it can't run in a machine that only has .net framework 4.0 installed in C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0  but without that in C:\Windows\Microsoft.NET\Framework\v4.0.30319.

    How to I compile the project to have .net framework 4 refer to the one in  C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0.

    Kindly advise.

    Thank you.


    TS Lim


    • Edited by TS Lim Monday, December 16, 2013 3:49 AM small typo error
    Monday, December 16, 2013 3:27 AM

Answers

  • I finally got the root of the problem. It is due to the obsfucaition of the exe.

    I remove some of the obsfuction protection functions, the  exe then can run properly.

    It could be due  to some compatitbility issue of the obsfucation. No problem for Win 7 machine when compile with .net frame work 2 or 4. No problem with Win 8 machine when compile with .net framework 2 but give problem when compile with .net framework 4.

    Anyway thanks to you, Parakash, I did learn some new thing from you.


    TS Lim



    • Marked as answer by TS Lim Tuesday, December 17, 2013 7:42 AM
    • Edited by TS Lim Tuesday, December 17, 2013 7:43 AM
    Tuesday, December 17, 2013 7:42 AM

All replies

  • You cannot control the path from where a .Net framework assembly will be loaded. It'll always be loaded from GAC.

    Also, you cannot change .net framework install path. It'll always be installed on your system drive.

    Probably you don't have .net framework installed(or partially installed) on the machine where you're facing the issue.


    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.

    Monday, December 16, 2013 4:00 AM
  • In Window 8, the path for .net Framework 4 is at C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0 .

    I want my project to be used by Window 8 users. How to solve this problem?


    TS Lim

    Monday, December 16, 2013 4:11 AM
  • The assemblies that are present in this directory is for compilation purpose only. At runtime, it'll always load from GAC.

    This folder is one of the part of total .Net framewirk installation and not the .Net framework itself. It is there to help you add references to your project and compile it.

    I would suggest you create a one liner console project on your development box and drop the exe on the Win8 machine and run it there.

    If mscorlib is available then it should run correctly else there should be a FileNotFound exception.

    Also, can you please share what error you're getting while running your vb.net project on Win8 machine ? 


    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.

    Monday, December 16, 2013 6:15 AM
  • I think I got what you mean.

    Just to confirm I understood your explanation correctly. Below I elaborate what I do and what I think.

    I am using Win7 machine with Visual Studio 2010.
    I have a vb.net project that compiled with .net Framework 4.0.

    When I run the exe on my Win7 machine, at runtime the GAC will direct the path for .net framework 4.0 to C:\Windows\Microsoft.NET\Framework\v4.0.30319.

    If it is run in Win8 machine, the GAC will direct the path for .net framework 4.0 to C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0 .

    If the above is correct, then the question is answered.

    Thank you very much.

    For the problem the user faced when loading my exe to his Win8 machine, I will check with him on what exactly is the problem.


    TS Lim

    Monday, December 16, 2013 6:57 AM
  • The GAC folder remains same for Win7 or Win8.

    It'll be "C:\Windows\Microsoft.Net\Assembly". As I said earlier, you can control path of assembly for compilation only.

    For a stongly named assembly, the version + platform + culture + public key token will derive which exact assembly to load.

    In GAC, there can be n number of assembly having the same name but different versions (ex. there can be two x.dll in GAC that has different versions).

    At runtime, if your exe referes to x.dll, based on what version you're referring it'll load the correct x.dll.

    Hope it helps.


    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.

    Monday, December 16, 2013 7:11 AM
  • Also, to know from where(path) an assembly is being loaded at runtime you can use Fusion Log Viewer tool (fuslogvw.exe) available with .Net SDK.

    That will give you detailed information about runtime binding mechanism .Net uses.


    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.

    Monday, December 16, 2013 7:13 AM
  • In my Win7 machine, I did a try to run the exe that is compiled with .net framework 4 (full verison and client version)  in two different scenario.

    One is I run it while the folder of C:\Windows\Microsoft.NET\Framework\v4.0.30319 remains.

    The other is, I delete the folder and run the exe.

    The first one run smoothly.

    Second one just cannot start ( for full version .net framework 4).

    It give exceptionn and promopt to install v4.030319 (for client version .net framework 4).

    Any advise from you under this scenario?


    TS Lim

    Monday, December 16, 2013 8:15 AM
  • Any specific reason for deleting the folder ?

    If you install a program and then delete files created in program files directory by the installer. Then try to run that program from start menu. What happens ?


    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.

    Monday, December 16, 2013 8:39 AM
  • Here is the problem faced by Win8 users when runing the exe compiled with .net framework 4 with Visual Studio 2010.

    When double click at the exe file. Can only see the cursor turning forever and nothing happen.

    Any advise ?


    TS Lim

    Monday, December 16, 2013 8:41 AM
  • Does this happens with any .Net applicattion ?

    Have you tried creating a simple console app and running that.  Also if the folder doesn't exist under "C:\Windows\Microsoft.NET\Framework", I would suggest to reinstall .Net framework so that you get the folder back.

    It is recommended that no directories should be deleted under C:\Windows(except Temp) otherwise the system may misbehave.


    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.

    Monday, December 16, 2013 8:50 AM
  • The reason the delete the folder is to test whether the exe is dependent on the assemblies on the folder to run. From the test can we say it depends on that and  not from the C:\Windows\Microsoft.Net\Assembly?

    On the scenaio you  gave, it will give alert that the  file is missing. 


    TS Lim

    Monday, December 16, 2013 8:58 AM
  • Actually, it the test, I did not delete the folder. I just rename the folder, do the test and rename it back.

    For the Win8 users, there is no deletion of any file.

    Can  you advise whether Win8 comes with assemblies in C:\Windows\Microsoft.NET\Framework or does it need seperate installation?


    TS Lim

    Monday, December 16, 2013 9:05 AM
  • That folder is part of .Net framework and it comes preinstalled with Windows 8.


    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.

    Monday, December 16, 2013 9:26 AM
  • How about folder  v4.0.30319 under and the assmblies under C:\Windows\Microsoft.NET\Framework ?


    TS Lim

    Monday, December 16, 2013 9:42 AM
  • I finally got the root of the problem. It is due to the obsfucaition of the exe.

    I remove some of the obsfuction protection functions, the  exe then can run properly.

    It could be due  to some compatitbility issue of the obsfucation. No problem for Win 7 machine when compile with .net frame work 2 or 4. No problem with Win 8 machine when compile with .net framework 2 but give problem when compile with .net framework 4.

    Anyway thanks to you, Parakash, I did learn some new thing from you.


    TS Lim



    • Marked as answer by TS Lim Tuesday, December 17, 2013 7:42 AM
    • Edited by TS Lim Tuesday, December 17, 2013 7:43 AM
    Tuesday, December 17, 2013 7:42 AM