VS2010 and GAC Installation

Jun 1, 2011 at 7:31 PM

Hi,

When we tried building our project (still on .net 3.5) with VS2010 we got a strange failure. After some investigation we got the following results:

  1. All our NTrace references are pointing to the v2.0 version.
  2. We got one assembly X.dll installed to the GAC during post build. This assembly is using NTrace.
  3. We have another assembly Y.dll built right after X.dll and referencing it - this one failed to build complaining about incorrect .net fx version - we saw that with VS2010 it's loading NTrace from the GAC, which is .net 4 based (v4.0), hence the failure. We had some very hard time removing NTrace from the GAC (it refused to uninstall saying Windows Installer needs it - we had to manually delete the file), and then buid successfully passed (as it took the correct v2.0 NTrace).

My questions are:

  1. Why NTrace is installed to GAC on dev environment, while it's not the case anyway in production environment?
  2. Is it possible to install both NTrace version (v2.0 and v4.0)? Would this resolve the problem we had?
  3. Would it make sense to install v2.0 to GAC for both vs2008 and 2010?

Thanks,

--Eran,

 

 

Coordinator
Jun 1, 2011 at 9:19 PM

The GAC’ed assemblies are there to allow the project templates to “just work.” Since project templates don’t have a way to dynamically set things like paths (without implementing a project template wizard, that is) it’s easier to simply omit the HintPath and have it pick it up from the GAC. Since the installer is what put the assembly in the GAC, the GAC will complain about attempts to uninstall the assembly (it knows it was an MSI component). The reason we have two versions of the NTrace assembly (one in the 2.0 GAC, the other in the 4.0 GAC) is so that pure 4.0 apps don’t have to load the 2.0 runtime.

Let me make sure I understand your scenario here: you have a .NET 4.0 project referencing a .NET 3.5 assembly, and both are using NTrace? If that’s the case, simply re-point the 4.0 project to use the 3.5 version of NTrace (found in Program Files\NTrace\v2.0). Since you’re already referencing a 2.0 runtime assembly, you’ve already decided that you’re OK with hosting both runtimes in your process.

Let me know if that does the trick for you.

-Andy Hopper

From: eranhare [email removed]
Sent: Wednesday, June 01, 2011 3:31 PM
To: andy@hoppersoft.com
Subject: VS2010 and GAC Installation [NTrace:259837]

From: eranhare

Hi,

When we tried building our project (still on .net 3.5) with VS2010 we got a strange failure. After some investigation we got the following results:

1. All our NTrace references are pointing to the v2.0 version.

2. We got one assembly X.dll installed to the GAC during post build. This assembly is using NTrace.

3. We have another assembly Y.dll built right after X.dll and referencing it - this one failed to build complaining about incorrect .net fx version - we saw that with VS2010 it's loading NTrace from the GAC, which is .net 4 based (v4.0), hence the failure. We had some very hard time removing NTrace from the GAC (it refused to uninstall saying Windows Installer needs it - we had to manually delete the file), and then buid successfully passed (as it took the correct v2.0 NTrace).

My questions are:

1. Why NTrace is installed to GAC on dev environment, while it's not the case anyway in production environment?

2. Is it possible to install both NTrace version (v2.0 and v4.0)? Would this resolve the problem we had?

3. Would it make sense to install v2.0 to GAC for both vs2008 and 2010?

Thanks,

--Eran,

Jun 2, 2011 at 1:10 PM
I'll elaborate a bit more on our case - All the projects in our solution are built with Target Framework=3.5. In, addition, all references to NTrace within the project file are to the specific location of v2.0.
Once we moved to VS2010 (however still keeping target framework 3.5) we got the following warning (which is actually an error):
c:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3258: The primary reference "MyAssembly" could not be resolved because it has an indirect dependency on the .NET Framework assembly "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which has a higher version "4.0.0.0" than the version "2.0.0.0" in the current target framework.
(I get a similar warning for System, System.Xml and some additional assemblies).

Looking at MyAssmebly with a tool like .Net Reflector shows that it has a reference to the .net 4.0 version of NTrace (which depends on .net 4.0 versions of system,mscorlib,etc...), hence the failure. This is done although I specifically give the path of the v2.0 NTrace as a reference to the assembly.
When I remove NTrace from GAC everything compiles fine.

Why VS takes NTrace from the GAC although specifically given the correct path? Is there a way to make VS not taking the reference from GAC?
Why VS2010 takes it from 4.0 GAC and not from 2.0 GAC?

I hope the problem is clearer now:)

Thanks,
--Eran

From: [email removed]
To: [email removed]
Date: Wed, 1 Jun 2011 14:19:45 -0700
Subject: Re: VS2010 and GAC Installation [NTrace:259837]

From: ahopper
The GAC�ed assemblies are there to allow the project templates to �just work.� Since project templates don�t have a way to dynamically set things like paths (without implementing a project template wizard, that is) it�s easier to simply omit the HintPath and have it pick it up from the GAC. Since the installer is what put the assembly in the GAC, the GAC will complain about attempts to uninstall the assembly (it knows it was an MSI component). The reason we have two versions of the NTrace assembly (one in the 2.0 GAC, the other in the 4.0 GAC) is so that pure 4.0 apps don�t have to load the 2.0 runtime.

Let me make sure I understand your scenario here: you have a .NET 4.0 project referencing a .NET 3.5 assembly, and both are using NTrace? If that�s the case, simply re-point the 4.0 project to use the 3.5 version of NTrace (found in Program Files\NTrace\v2.0). Since you�re already referencing a 2.0 runtime assembly, you�ve already decided that you�re OK with hosting both runtimes in your process.

Let me know if that does the trick for you.

-Andy Hopper

From: eranhare [email removed]
Sent: Wednesday, June 01, 2011 3:31 PM
To: andy@hoppersoft.com
Subject: VS2010 and GAC Installation [NTrace:259837]


From: eranhare
Hi,
When we tried building our project (still on .net 3.5) with VS2010 we got a strange failure. After some investigation we got the following results:

1. All our NTrace references are pointing to the v2.0 version.

2. We got one assembly X.dll installed to the GAC during post build. This assembly is using NTrace.

3. We have another assembly Y.dll built right after X.dll and referencing it - this one failed to build complaining about incorrect .net fx version - we saw that with VS2010 it's loading NTrace from the GAC, which is .net 4 based (v4.0), hence the failure. We had some very hard time removing NTrace from the GAC (it refused to uninstall saying Windows Installer needs it - we had to manually delete the file), and then buid successfully passed (as it took the correct v2.0 NTrace).

My questions are:

1. Why NTrace is installed to GAC on dev environment, while it's not the case anyway in production environment?

2. Is it possible to install both NTrace version (v2.0 and v4.0)? Would this resolve the problem we had?

3. Would it make sense to install v2.0 to GAC for both vs2008 and 2010?

Thanks,
--Eran,


Read the full discussion online.
To add a post to this discussion, reply to this email (NTrace@discussions.codeplex.com)
To start a new discussion for this project, email NTrace@discussions.codeplex.com
You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.
Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com
Jun 2, 2011 at 2:14 PM

OK  - I think I got to the bottom of it and found a reasonable workaround (for uninstalling NTrace from the GAC is not a reasonable workaround:))

MyAssembly described in my previous post doesn't have a reference to NTrace - it has a reference to Utilities.dll assembly which has a (relative path) reference to NTrace, and get built without any problem.

When I changed 'Copy Local' property of Utilities from (default) false to true, everything got built fine. My assumption is that when building MyAssembly it loads Utilities and continues to load utilities' references - since NTrace is not located in utilities folder, it starts looking for it in GAC and takes it from there (still no idea, however, why from 4.0 GAC and not from 2.0 GAC). When changing Local Copy to true, I guess it simply takes the (correct) version of NTrace from utilities folder.

Any takes on that?

--Eran