473,725 Members | 2,276 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to get the 4-part name of an assembly via reflection

Trying to use reflection to obtain the 4-part name of a strong named assembly
(assembly, version, culture, publickeytoken) and immediately release the
reference. I’m currently doing the following:

Assembly projectAssembly =
Assembly.Reflec tionOnlyLoadFro m(projectAssemb lyFullPath);
fourPartName = projectAssembly .FullName;
projectAssembly = null;

The problem is that the reference to the assembly is still being held after
I set it to null which isn’t ideal… this is keeping Visual Studio from
building the project as it can’t overwrite the assembly in the \bin\debug
directory (this is a plugin-like project I’m working on). Looking for any
method to force a release of the assembly or another process to obtain this
4-part name. Ideas?

--
-AC [MVP MOSS]
http://www.andrewconnell.com
http://www.andrewconnell.com/mvp
http://www.andrewconnell.com/blog

Jul 25 '07 #1
4 1308
* AC [MVP MOSS] wrote, On 25-7-2007 17:50:
Hmm... I'm a bit unclear how to do this. Maybe a bit more context helps...

The plugin is running within the context of VS 2005. I need to quickly
relfect an assembly to grab the 4-part name and then release it. The problem
is that I can't dump the app domain because that dumps VS 2005. As long as
it's got a handle to the assembly loaded, VS can rebuild the project really
killing my solution.

Maybe there's another way to get the 4-part name w/o reflection?
You need to create a new (temporary) AppDomain in you process. You can
then use a class you've loaded in your new AppDomain to load the
assembly in the new domain, get the info with reflection and return it
your old AppDomain. Then from the old AppDomain unload the temporary
AppDomain.

I don't have the code handy and it needs some experimenting to get it
right. Maybe someone can jump in and help you further.

Jesse
Jul 25 '07 #2
Ah... now that sounds like the trick. I'm sure I can figure this out with the
SDK... thanks Jesse!

--
-AC [MVP MOSS]
http://www.andrewconnell.com
http://www.andrewconnell.com/mvp
http://www.andrewconnell.com/blog

"Jesse Houwing" wrote:
* AC [MVP MOSS] wrote, On 25-7-2007 17:50:
Hmm... I'm a bit unclear how to do this. Maybe a bit more context helps...

The plugin is running within the context of VS 2005. I need to quickly
relfect an assembly to grab the 4-part name and then release it. The problem
is that I can't dump the app domain because that dumps VS 2005. As long as
it's got a handle to the assembly loaded, VS can rebuild the project really
killing my solution.

Maybe there's another way to get the 4-part name w/o reflection?

You need to create a new (temporary) AppDomain in you process. You can
then use a class you've loaded in your new AppDomain to load the
assembly in the new domain, get the info with reflection and return it
your old AppDomain. Then from the old AppDomain unload the temporary
AppDomain.

I don't have the code handy and it needs some experimenting to get it
right. Maybe someone can jump in and help you further.

Jesse
Jul 25 '07 #3
* AC [MVP MOSS] wrote, On 25-7-2007 20:22:
Ah... now that sounds like the trick. I'm sure I can figure this out with the
SDK... thanks Jesse!
You're welcome. Good luck ;)

Jesse
Jul 25 '07 #4
>Maybe there's another way to get the 4-part name w/o reflection?

System.Reflecti on.AssemblyName .GetAssemblyNam e(projectAssemb lyFullPath)

You could argue that that is actually using Reflection, but at least
it doesn't require loading the assembly.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Jul 31 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3391
by: kjon | last post by:
Hi, I want to obfuscate my DLL assembly which also has a strong name. As I know that the obfuscated assembly with strong name won't work, and have tried using AssemblyDelaySign(True) and sn.exe -R my.dll key.snk but still don't work. Just want to make sure what is the proper way to achieve this? I thought this might be a common task but just can't find any on the web which can tell it more clearly. Thanks for any advice.
2
1458
by: Microsoft | last post by:
Hello I want make my assembly strong named. Now I have the Error "Microsoft.Practices.EnterpriseLibrary.Logging.dll is not strong named" What can I dou ? It's possible to make a strong named assembly us Microsoft.Practices.EnterpriseLibrary.Logging.dll ?
1
3221
by: Jeff Molby | last post by:
Sorry for the crossposting guys. I figured this one might be a little tricky, so I'm calling upon the C# brains out there to help out this poor VB developer. I know enough C# to translate any code you can offer, if necessary. I have a very loosely coupled WinForms app written in VB.Net, Framework v1.1 I need to take a string value which contains the unqualified name of a class, find the assembly that contains such a class, and...
1
1721
by: | last post by:
I have two assemblies with exactly the same name, but which are different; one is on the local machine and the other comes from a remote one. I want to deserialize an object which is of a type of the remote assembly. How can I do this since my deserializer says "Type is not resolved for member ..." I think the remote assembly is loaded though (I did it with an AssemblyResolveHandler that catch any AssemblyResolve event and returns...
2
3690
by: JW | last post by:
Dear NG, I am writing a .NET CF forms app. that needs to dynamically configure buttons on a form. Since the forms designer doesn't like component arrays I am using ordinary instance names for each button (btn0, btn1 etc.) as private members of the form class, but need to reference these from a loop that is iterating through the button config. information (array). My question is how can I loop through a collection of buttons with names...
3
4130
by: Richard | last post by:
Hi, We would like our application to be signed and have a strong name. However our application references a 3rd party .dll that does not have a strong name and so when we compile we get the dreaded compiler error: Assembly generation failed -- Referenced assembly 'Xxxxxxxxx' does not have a strong name Is there any way - perhaps with attributes - that my strong named assembly
3
4817
by: Annie | last post by:
After assigning a key to a DLL to make it a strong name assembly, it cannot be compiled to the same location again. The VS.NET always shows "Could not copy temporary files to the output directory. The file 'xxx.dll' cannot be copied to the run directory. The process cannot access the file because it is being used by another process. and the DLL file is locked and cannot be deleted or overwritten This is probably the effect of assigning the...
1
1060
by: MS Newsgroups | last post by:
Hi, For different reasons would like to strong name my web application, but am unable to do so. When I try to build my project with the AssemlyKeyFile attribute set in Assemblyinfo, I get a error message saying Unable to emit assembly: Referenced assembly 'DateTextBox' does not have a strong name. DateTextbox in this case is a thirdparty control that I am using in my project (Have no source code for this). Is there any workaround to this...
2
1089
by: Scott Eguires | last post by:
Is there a way to determine the name of a class instance using reflection or by some other means? For example suppose a delegate is fired, I would like to know the name of the Instance of the suscriber class whose method is being called: Say I have two suscriber classes: dim clsSub1 as CSuscriber dim clsSub2 as CSuscriber
2
1598
by: bigtexan | last post by:
Simple question I hope. class A { void SomePropertyName { set { string NameOfThisProperty = ??? // what code here to
0
8752
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9401
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9116
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8099
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6702
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6011
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4519
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4784
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3228
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.