how dynamically change path of strong name key file in windows form

Sanmarie
Sanmarie used Ask the Experts™
on
Using .net 1.1, windows forms

I created an assembly/dll and placed it in the global assembly cache. In the assemblyInfo file I have to put the path to the strong name key file like so:

<Assembly: AssemblyKeyFile("C:\My Documents\MyDll\bin\MyDll.snk")>

How can I dynamically set this path at runtime?

Thanks

San
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
What will decide what the path will be?

You can set a global variable, and whenever your app knows what the path will be, set it to that?

Or will that file 'follow' your app wherever its installed? if so, you can use 'application.startuppath'

Author

Commented:

The problem was when I created the strong name key, I set the path to it on my machine. When my co-worker installed it, he got an error saying key not found because he didn't have the path set up.

I want the path to be independent of the machine. I just don't know how to go about it. How do I use application.startuppath?

Thanks

San
Application.StartupPath = the path the executable is run from.

If your exe is in C:\MyApp\ and the DLL is in c:\YourApp\Dll then you would use:

Application.StartupPath & "\Dll\MyDll.snk"

And it would equate to:

C:\YourApp\Dll\MyDll.snk

It wouldn't matter what machine your using, or where the exe path is, as long as your DLL is always in the DLL directory of your Application directory (if that makes sense!?)
sorry... C:\MyApp and C:\YourApp were meant to be the same directory... typo there lol

Author

Commented:

Thanks

I will try it out later and post a new question if any doubts
If you have any doubts/queries... just post in this thread. Ill carry on answering until its working.

Dez

Author

Commented:

Will do today if any problems.

Thanks

San

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial