whats is the difference between regsvr32 and GAC? - gac

Whats is the difference between regsvr32 and GAC?
Of course regsvr32 is for COM and GAC is for .net assemblies but is that the only difference?

regsvr32 is a program which is used to self-register dlls.
The GAC is a versioned store for .Net assemblies.
They're not really comparable.

Related

Does a COM DLL have to be compiled and registered for each bit edition?

Is it OK for a COM DLL to be compiled as AnyCPU and work with both 32 bit and 64 bit applications?
Yesterday I started writing a C# COM DLL so that my MFC project could use the DLL. The DLL itself is for using the GMail API.
Initially I was compiling the DLL as either x86 or x64 and both of my executables were running fine.
Then I decided to change the DLL to compile as AnyCPU and now when my program runs it says Class not registered.
Does the DLL have to be compiled for each Bit edition then?
No, you can keep the .DLL compiled as "Any CPU" (in fact I certainly recommend it as long as you can), but you must register it in each version of the registry, so for example using regasm:
64-bit:
c:\Windows\Microsoft.NET\Framework64\v4.0.30319\RegAsm.exe ClassLibrary1.dll /codebase /tlb
32-bit:
c:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe ClassLibrary1.dll /codebase /tlb

DLLs won't register under 32-bit or 64-bit. How do I register them?

I've copied my dlls into both C:\windows\System32 and C:\windows\SysWoW64, and have executed regsvr32.exe into both of them, and have ended up with an error message telling me that name.dll may be incompatible and that I should try registering under the other folder.
Side note: I am running cmd as an administrator. I have Windows 7, 64-bit OS.
Edit: Also, I have confirmed that the dlls are 32-bit.
Is your DLL a COM DLL
The Regsvr32 Tool (regsvr32.exe) is used to register or un–register a COM DLL.
Regsvr32

how to avoid manual work of copying dll files to other PC

how acually DLL concept works for vb.net project
I have included Microsoft.office.interop.excel dll and sqlite dll
but in other PC, excel dll gets automatically installed with setup
while sqlite dll, I need to manually put in GAC
why it is so ??
any solution, so that I can avoid manual work of copying...
You could provide an installer/setup with your application to install the assemblies in the GAC. Or just provide all the assemblies in the same directory as your application. If the assemblies are not yours, then please check if and how you can redistribute it.

Where is the .NET Framework Global Assembly Cache?

I installed the VS2010 and .NET 4.0, then I compiled an assembly and ran the gacutil using the exe available on
%ProgramFiles%\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools
The output of the executable said the assembly was sucessfully installed on Global Assembly Cache. However, when I go to %WINDIR%\assembly folder I cannot find the assembly I installed using the .NET Framework 4.0 gacutil.
I've seen some posts saying the .NET Framework 4.0 has a separated GAC, but what I haven't found was where it is located.
May someone to help me to check where can I see the Global Assembly Cache of .NET Framework, as it used to work on previous version (%WINDIR%\assembly)?
Yes, there are two distinct GACs as from .NET 4.0
See here: .NET 4.0 has a new GAC, why?
As stated below, the new physical location is %windir%\Microsoft.NET\assembly\ (you can interogate it using the dir command at a command prompt if you're interested).
It's worth noting that applications running up to the 2.0 CLR will not even be able to see assemblies in the new GAC.
Try:
%windir%\Microsoft.NET\assembly\
Due to Common Language Runtime (CLR) changes, the contents of the Global Assembly Cache (GAC) is split between two directories:
%WINDIR%\assembly\
%WINDIR%\Microsoft.NET\assembly\
If you run the command gacutil -l from the directory of your project's .csproj file, you will get a printout of the contents of the GAC (the contents of both directories).

C# COM DLL: do I use Regasm, or Regsvr32?

I am building a C# ActiveX DLL... do I use REGASM or REGSVR32 to register it?
How do I register the 64-bit interface vs the 32-bit interface?
You need to use regasm.exe to register both the 32 bit and 64 bit interfaces I believe you need to run each of the regasm.exe's in:
C:\Windows\Microsoft.NET\Framework\v2.0.50727
and
C:\Windows\Microsoft.NET\Framework64\v2.0.50727
So... in your case you need to run the regasm.exe in the Framework64\v2.0.50727 folder.
Here's an example we use to register a COM interop DLL for one of our legacy ASP apps:
regasm.exe Hosting.DeviceManager.Power.dll /register /codebase /tlb
If the DLL is build in format of "Any CPU", no matter if you choose regasm in
C:\Windows\Microsoft.NET\Framework\v2.0.50727
or
C:\Windows\Microsoft.NET\Framework64\v2.0.50727
DLL would be registered as 32-bit.