473,386 Members | 1,924 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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.ReflectionOnlyLoadFrom(projectAssemblyFul lPath);
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 1295
* 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.Reflection.AssemblyName.GetAssemblyName(pro jectAssemblyFullPath)

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
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...
2
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...
1
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...
1
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...
2
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...
3
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...
3
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....
1
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...
2
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...
2
by: bigtexan | last post by:
Simple question I hope. class A { void SomePropertyName { set { string NameOfThisProperty = ??? // what code here to
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...

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.