|
Unfortunately that returns the directory of the executable directory
As an extended example I have the a DLL which is located here :
C:\Gactest\RefTestDll.dll
Which has the following code :
using System;
namespace RefTestDll
{
public class Dll
{
public string GetRefDirectory()
{
return System.Reflection.Assembly.GetEntryAssembly().CodeBase;
}
}
}
This dll is added to the GAC
I then have an application located here :
c:\GacTestApp\gactestapp.exe
Which uses the GAC reference to the DLL mentioned above using the following code:
using System;
namespace RefTestApp
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
RefTestDll.Dll d = new RefTestDll.Dll();
Console.WriteLine(d.GetRefDirectory());
}
}
}
The only directories I seem to be able to get back from the Reflection namespace is either the real GAC directory or the directory of the calling application.
|
|
|
|
|
It seems that I have found a solution, its nasty, its hacky, it probably wont be reliable but at the moment it seems to work.
When an assembly is entered into the GAC it is placed into the following directory :
c:\windows\assembly\GAC\[assembly name]\[assembly name]_[strong name]\
This directory also contains the following file :
__AssemblyInfo__.ini
This INI file contains a URL parameter which contains the path I need
using the following code:
private static string GetConfigPath(string configFileName)
{
string assemblyDirectory = string.Empty;
Assembly executingAssembly = Assembly.GetExecutingAssembly();
if( ( true == executingAssembly.GlobalAssemblyCache ))
{
IniReader iniReader = new IniReader(String.Format( @"{0}\{1}", System.IO.Path.GetDirectoryName(executingAssembly.Location), "__AssemblyInfo__.ini" ) );
assemblyDirectory = System.IO.Path.GetDirectoryName( iniReader.ReadString("AssemblyInfo", "URL", "") );
}
else
{
assemblyDirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase);
}
return String.Format(@"{0}\{1}", assemblyDirectory, configFileName );
}
I can get the directory + the file name I specify
This function relies on an IniReader class which I obtained from:
http://www.mentalis.org
As mention above, this works but IMHO it hacking as hell, I am also not overly impressed that this sparkly .NET Framework thing uses INI files.
post.mode = postmodes.signature;
SELECT everything FROM everywhere WHERE something = something_else;
> 1 Row Returned
> 42
|
|
|
|
|
Hello gurus,
I'd like to know how it is possible to serialize the content of an ImageList class?
I wish to load and save the content of an ImageList from/to a file.
Can someone show me a code snipet please?
Best regards.
Fred.
There is no spoon.
|
|
|
|
|
|
And how to do that???
Fred.
There is no spoon.
|
|
|
|
|
Hello...
Here is an example without exception handling:
// serialize
FileStream fs = new FileStream("C:\\imagelist.iml",FileMode.CreateNew);
BinaryFormatter bf = new BinaryFormatter();
bf.Serialize(fs,il.ImageStream);
fs.Close();
// deserialize
FileStream fs = new FileStream("C:\\imagelist.iml",FileMode.Open);
BinaryFormatter bf = new BinaryFormatter();
il.ImageStream = (ImageListStreamer)bf.Deserialize(fs);
fs.Close();
|
|
|
|
|
After searching for a few "minutes", that's the way I have found in the MSDN.
It works fine.
Thanks
Fred.
There is no spoon.
|
|
|
|
|
Hi all,
any one can tell me how to maintain my form window on the desktop and not minimized when the user presses LWin (win logo) + D
thanks
kevin smoke
|
|
|
|
|
The only way to do that is to use a Low Level Keyboard hook. There are articles on this here at CP. Just don't pass that key combination to the next handler.
Also, Microsoft does NOT recommend doing this in their UI Guidelines. If I need to get to the desktop and your app gets in my way, my next mouse clicks go straight to Add/Remove programs...
Articles[^]
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Here's my problem:
When I load an assembly that has been renamed (its filename is not the same as the one in the manifest), loading it throws an exception.
I have tried both AppDomain.Load(byte[]) and having it be auto-loaded using AppDomain.CreateInstance(string, string) and both throw exceptions. (Serialization exception in the Load() case and some obscure assembly load exception in the second case).
I haven't tried Assembly.Load() since I need to load it in another domain and I haven't found a way to use it for that.
What's going on? How can I get it to ignore the name in the manifest and just load the assembly I give it?
|
|
|
|
|
|
That can't be it - the original assembly does not exist, only the renamed one.
|
|
|
|
|
|
No, it can't be.
What I do is compile my assembly, rename it and then run the app. The original assembly is never even known to the app, so it could never load it...
|
|
|
|
|
|
Hi,
I am looking for some way that you can drag and drop a columnheader and create a group based on that. I know there is a lot of third party software doing this, but they more or less all look the same, so I am wondering whether this is somekind of standard feature provided by the grid or that it is realy simple to code. Normally I would find something about this in the articles section as it is a quite common feature, but i couldn't find anything there. Any suggestions?
Cheers
DJ
Think, try, think, think, try, think, think, think, try, ASK, think, try, advance on step and start over...
|
|
|
|
|
David M J wrote:
but they more or less all look the same
they look the same because they doing the same task but internally they differ in thier architecture and each one has its Pros and Cons
David M J wrote:
so I am wondering whether this is somekind of standard feature provided by the grid or that it is realy simple to code
Making grid look like third party grids is complex task
MCAD
|
|
|
|
|
how can i extract the icon from an exe file and display it in a icon list view box and how can can i control the properties of each icon separately like a triggering a different event on clicking a different icon?
|
|
|
|
|
To Extract Icon From dll or exe use ExtractIconEx
<br />
[DllImport("shell32.dll", CharSet=CharSet.Auto)]<br />
static extern uint ExtractIconEx(string szFileName, int nIconIndex, IntPtr[] phiconLarge, IntPtr[] phiconSmall, uint nIcons);<br />
Use it to get IconHandle from the file
Then using this handle to create Icon class by calling
icon.FromHandle()
So you can use this Icon class to do what you want
For example look at
http://www.pinvoke.net/default.aspx/shell32/ExtractIconEx.html[^]
MCAD
|
|
|
|
|
As my application grows, task list shows me more and more warnings and I want to put them out.
It's easy to remove most of them, like unused fields, but what to do with unused events?
I've declared some events in interface and not every class raises these events. So I've got a warning.
The interface is IWizardPage and classes are wizard pages. Event handlers for typical events of wizard pages (like wizard buttons update) are hooked up in WizardSheet dialog, so it will be dummy not to declare events in interface.
|
|
|
|
|
|
How to make our winform application custom skin like yahoo change its skin base on different images and ini file setting.
I mean Form Title Window and whole skin color change shape does'nt matter.
If any Body have any Idea. Please Tell Me
Muhammad Waqas Butt
waqasb4all@yahoo.com
Muhamad Waqas Butt
waqasb4all@yahoo.com
Muhamad Waqas Butt
waqasb4all@yahoo.com
|
|
|
|
|
Hi, can anyone tell me how to assign an autonumber to a record in SQL Server2000 database
can that be done in SQL database or do i need to write code in my application. if so, i need code in C#. as im making an ASP.NET web application using c#
thanx
|
|
|
|
|
If you need field to be auto number in sql server enterprise manager set identity to yes
MCAD
|
|
|
|
|
hi everybody.
Please I want anyone here to help me finding the right idea on how to establish session for file transmission using peer to peer technology and to let users connect to that session and begin receiving the file from one user connected in the same session any help of code or an article for that please !!!
Miss With The Best And Die Like The Rest
|
|
|
|