Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - Shared Assembly in GAC and its dependencies assemblies

Reply
 
Old 09-03-2008   #1 (permalink)
MA


 
 

Shared Assembly in GAC and its dependencies assemblies

Hi,

We have added a shared assembly in GAC so that our multiple solutions
can use use it. We use the publisher policy to controls the different
versions of the assembly.

This shared assembly also has dependencies (some are .NET assembly
with strong name and some non .NET without strong name). How we will
manage the dependent assemblies? Does the dependent assemblies will
need to be added to the GAC?

Obviously we will not able to add the weak name assembly to the GAC.
How can we manage one copy of the weak named assembly so that we can
update in future?

We will prefer not make local references of the dependent assemblies
(i.e. assemblies will need to be exists in solution installation
folder) so that we can update the dependent assemblies if required
without updating each solution.


Example:
Assembly1: depend on Assembly2 (strong named) & Assembly3 (weak
named).
Assembly1 added to the GAC. Do we need to add the Assembly2 to the GAC
as well? The Assembly3 is not strong named, how we will manage the
Assembly3? Does each solution will need the local copy of the
Assembly3 or can we add to the "c:\program files\shared" and manage it
centrally?


Hope this make sense and thanks in advance for your suggestions.

Regards,
MA

My System SpecsSystem Spec
Old 09-03-2008   #2 (permalink)
MA


 
 

Re: Shared Assembly in GAC and its dependencies assemblies

Hi,

I have came across the article below which recommend to place the un-
managed assembly to the GAC by creating a managed wrapper assembly.
This approach answer the issue above where we will need to put all the
dependent assemblies to GAC (managed+un-managed).

http://blogs.msdn.com/yizhang/archiv...-into-gac.aspx

Quote:
Let's say you have a managed wrapper assembly Managed.dll that calls
unmanaged code Unmanaged.dll using P/Invoke. If you want to register
Managed.dll to GAC, you'll need to deploy Unmanaged.dll into GAC as
well, otherwise it would require extra work to be done so that
Managed.dll can find Unmanaged.dll. To deploy both Manage.dll &
Unmanaged.dll into GAC, you can create a multi-file assembly
consisting both Managed.dll & Unmanaged.dll. In order to create such a
assembly, you can:

1. Use /LinkResource option in C# compiler (CSC.EXE) if you are using
C#
2. Use /AssemblyLinkResource option in C++ compiler (CL.EXE) if you
are using managed C++
3. Use /Link option in Assembly Linker (AL.EXE)
Any Pros & Cons about this approach?

Regards,
MA


My System SpecsSystem Spec
Old 09-04-2008   #3 (permalink)
Pavel Minaev


 
 

Re: Shared Assembly in GAC and its dependencies assemblies

"MA" <malauddin@xxxxxx> wrote in message
news:9a70e445-916f-429e-8986-0f134d67f7f8@xxxxxx
Quote:

> Let's say you have a managed wrapper assembly Managed.dll that calls
> unmanaged code Unmanaged.dll using P/Invoke. If you want to register
> Managed.dll to GAC, you'll need to deploy Unmanaged.dll into GAC as
> well, otherwise it would require extra work to be done so that
> Managed.dll can find Unmanaged.dll. To deploy both Manage.dll &
> Unmanaged.dll into GAC, you can create a multi-file assembly
> consisting both Managed.dll & Unmanaged.dll. In order to create such a
> assembly, you can:
>
> 1. Use /LinkResource option in C# compiler (CSC.EXE) if you are using
> C#
> 2. Use /AssemblyLinkResource option in C++ compiler (CL.EXE) if you
> are using managed C++
> 3. Use /Link option in Assembly Linker (AL.EXE)
>

>
> Any Pros & Cons about this approach?
[/quote]

No cons that I know of, if you don't mind the extra work.

By the way, the same trick can be used to get the .pdb for your assembly to
be deployed to GAC automatically - just add it as a LinkResource.


My System SpecsSystem Spec
Old 09-04-2008   #4 (permalink)
MA


 
 

Re: Shared Assembly in GAC and its dependencies assemblies

Thanks for your response.

Btw, I have tried to create the wrapper assembly using the C#
compiler but without any success. The C# compiler (CSC) require a
target file (I am not sure what is the target file to enter). I want
to add the unmanaged.dll (written in Delphi) to the managed dll
(written in C#). Any suggestions?

Regards,
MA
My System SpecsSystem Spec
Old 09-04-2008   #5 (permalink)
MA


 
 

Re: Shared Assembly in GAC and its dependencies assemblies

Just another thought....

Can we have the local copy of the dependent assembly to the solution
installation folder? For example,

We have a AssemblyA (written in C#) which we added to the GAC.
AssemblyA has the references of AssemblyB (written in Delphi) and
other interop assemblies (un-managed).

Can we have the local copy of these un-managed assmblies to the
solution installation folder? How the assembly loader will work where
the AssemblyA in GAC but the dependencies are in solution installation
folder.

Thanks for your advice.

Regards,
MA
My System SpecsSystem Spec
Old 09-04-2008   #6 (permalink)
Pavel Minaev


 
 

Re: Shared Assembly in GAC and its dependencies assemblies

"MA" <malauddin@xxxxxx> wrote in message
news:5bf7f28f-ad17-4030-aaa1-90fdbea6bb13@xxxxxx
Quote:

> Btw, I have tried to create the wrapper assembly using the C#
> compiler but without any success. The C# compiler (CSC) require a
> target file (I am not sure what is the target file to enter). I want
> to add the unmanaged.dll (written in Delphi) to the managed dll
> (written in C#). Any suggestions?
Why not just use /linkresource when you compile your managed .dll?


My System SpecsSystem Spec
Old 09-04-2008   #7 (permalink)
Pavel Minaev


 
 

Re: Shared Assembly in GAC and its dependencies assemblies

"MA" <malauddin@xxxxxx> wrote in message
news:e687a2a0-4d73-4ec9-87aa-fc45835ccd73@xxxxxx
Quote:

> Just another thought....
>
> Can we have the local copy of the dependent assembly to the solution
> installation folder? For example,
>
> We have a AssemblyA (written in C#) which we added to the GAC.
> AssemblyA has the references of AssemblyB (written in Delphi) and
> other interop assemblies (un-managed).
>
> Can we have the local copy of these un-managed assmblies to the
> solution installation folder? How the assembly loader will work where
> the AssemblyA in GAC but the dependencies are in solution installation
> folder.
I'm afraid it won't work that way.


My System SpecsSystem Spec
Old 09-04-2008   #8 (permalink)
MA


 
 

Re: Shared Assembly in GAC and its dependencies assemblies

Thanks Pavel for your suggestions.

I have performed the steps below but seems the unmanaged.dll still
required by the solution. Any idea?

1. Compile the library.
Example: CSC /platform:x86 /errorreportrompt /out:"D:\test\bin
\Debug\MySystem.dll" /reference:"C:\WINDOWS\Microsoft.NET\Framework
\v2.0.50727\System.Windows.Forms.dll" /LinkResource:"D:\test
\unmanaged.dll" /target:library "D:\test\CommonTypes.cs" "D:\test
\Condition.cs" "D:\test\ConditionStatus.cs" /keyfile:"D:\test\Key.snk"

2. Add the "MySystem.dll" to GAC

3. In my Tester solution, add the shared GAC - "MySystem.dll" as
reference.
When I use a specific option in the Test solution which require the
unmanaged.dll I get the error "Function _xxxx raised exception 'Unable
to load DLL 'unmanaged.dll': The specified module could not be
found...."

If I add the unmanaged.dll to solution executaion location then it
works fine. Btw, we have used the DllImport to use the unmanaged.dll
which is not COM enabled.

[DllImport("unmanaged.dll", CharSet = CharSet.Ansi,
CallingConvention = CallingConvention.StdCall)]


Have we missed anything? Is there any other alternatives? Sorry to ask
many questions as new to this area of wrapped dlls. Thanks again for
your kind response.

Regards,
M.A
My System SpecsSystem Spec
Old 09-04-2008   #9 (permalink)
MA


 
 

Re: Shared Assembly in GAC and its dependencies assemblies

Thanks Pavel for your suggestions.

I have performed the steps below but seems the unmanaged.dll still
required by the solution. Any idea?

1. Compile the library.
Example: CSC /platform:x86 /errorreportrompt /out:"D:\test\bin
\Debug\MySystem.dll" /reference:"C:\WINDOWS\Microsoft.NET\Framework
\v2.0.50727\System.Windows.Forms.dll" /LinkResource:"D:\test
\unmanaged.dll" /target:library "D:\test\CommonTypes.cs" "D:\test
\Condition.cs" "D:\test\ConditionStatus.cs" /keyfile:"D:\test\Key.snk"

2. Add the "MySystem.dll" to GAC

3. In my Tester solution, add the shared GAC - "MySystem.dll" as
reference.
When I use a specific option in the Test solution which require the
unmanaged.dll I get the error "Function _xxxx raised exception 'Unable
to load DLL 'unmanaged.dll': The specified module could not be
found...."

If I add the unmanaged.dll to solution executaion location then it
works fine. Btw, we have used the DllImport to use the unmanaged.dll
which is not COM enabled.

[DllImport("unmanaged.dll", CharSet = CharSet.Ansi,
CallingConvention = CallingConvention.StdCall)]


Have we missed anything? Is there any other alternatives? Sorry to ask
many questions as new to this area of wrapped dlls. Thanks again for
your kind response.

Regards,
M.A
My System SpecsSystem Spec
Old 09-04-2008   #10 (permalink)
MA


 
 

Re: Shared Assembly in GAC and its dependencies assemblies

Thanks Pavel for your suggestions.

I have performed the steps below but seems the unmanaged.dll still
required by the solution. Any idea?

1. Compile the library.
Example: CSC /platform:x86 /errorreportrompt /out:"D:\test\bin
\Debug\MySystem.dll" /reference:"C:\WINDOWS\Microsoft.NET\Framework
\v2.0.50727\System.Windows.Forms.dll" /LinkResource:"D:\test
\unmanaged.dll" /target:library "D:\test\CommonTypes.cs" "D:\test
\Condition.cs" "D:\test\ConditionStatus.cs" /keyfile:"D:\test\Key.snk"

2. Add the "MySystem.dll" to GAC

3. In my Tester solution, add the shared GAC - "MySystem.dll" as
reference.
When I use a specific option in the Test solution which require the
unmanaged.dll I get the error "Function _xxxx raised exception 'Unable
to load DLL 'unmanaged.dll': The specified module could not be
found...."

If I add the unmanaged.dll to solution executaion location then it
works fine. Btw, we have used the DllImport to use the unmanaged.dll
which is not COM enabled.

[DllImport("unmanaged.dll", CharSet = CharSet.Ansi,
CallingConvention = CallingConvention.StdCall)]


Have we missed anything? Is there any other alternatives? Sorry to ask
many questions as new to this area of wrapped dlls. Thanks again for
your kind response.

Regards,
M.A
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
dependencies for WLPG Live Mail
MSINET.OCX dependencies Vista General
Using an interop assembly with interop dependencies PowerShell
appname.exe.manifest, DLL dependencies Vista General
Loading assembly dependencies with Powershell PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46