Task: Create an executable that works with a signed assembly (dll)
For openers, I am a dot net (csharp) newbie.
This is where I am at:
1) Created/compiled a dll. The name of the dll is UnixCrypt.dll (wraps a c# impl of unix crypt (i am not the author)).
2) Created/compiled/tested a test-driver executable that references UnixCrypt.dll. All functionality works.
3) Using the sn.exe tool created a public/private key file. In the UnixCrypt assembly manifest I have added the following line:
[assembly: AssemblyKeyFile(@"C:\public_private")]
... where "public_private" is the key-pair file generated from sn.exe.
4) Re-build the UnixCrypt assembly and verify that the assembly is signed using "sn -v" - it returns:
Assembly 'UnixCrypt.dll' is valid
Presumably all is well.
5) Not sure where to go next - this is my question! I want to build the test driver so that is works with (and only with) the signed version of UnixCrypt.dll. The outcome I am attempting to achieve is to create 2 versions of UnixCrypt.dll, one signed and one not signed and have the executable bomb when the non-signed version is substituted for the signed version. I am not sure how to build this dependency into the executable. I tried the following:
csc /t:exe TestUnixCrypt.cs /lib:<path_to_lib> /reference:UnixCrypt.dll
This builds fine, but it bombs at runtime (BTW - in the line above, the dll referenced is the signed version).
The stack trace probably tells me everything I need to know but I am not experienced enough with dot net to make sense of it all. I have put the stack trace at the bottom of this post.
I have spent some time looking through the sdk docs as well as msdn - I found some good answers on some points, some good confusion on others.
Any help here is appreciated. I need some help figuring out how to build the executable such that is depends on the signed assembly and only works with the signed assembly.
Thanks.
cporter
##########################################################
Unhandled Exception: System.IO.FileNotFoundException: File or assembly name UnixCrypt, or one of its depe
ndencies, was not found.
File name: "UnixCrypt"
at SomeCo.TestUnixCrypt.Main(String[] args)
=== Pre-bind state information ===
LOG: DisplayName = UnixCrypt, Version=1.0.931.34461, Culture=neutral, PublicKeyToken=7734614b473eaaae
(Fully-specified)
LOG: Appbase = C:\old_computer\d_drive\dev\Visual_Studio_Projects\TestUnixCrypt\TestUnixCrypt\
LOG: Initial PrivatePath = NULL
Calling assembly : TestUnixCrypt, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: Application configuration file does not exist.
LOG: Publisher policy file is not found.
LOG: Host configuration file not found.
LOG: Using machine configuration file from c:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\config\machine.co
nfig.
LOG: Post-policy reference: UnixCrypt, Version=1.0.931.34461, Culture=neutral, PublicKeyToken=7734614b473
eaaae
LOG: Attempting download of new URL file:///C:/old_computer/d_drive/dev/Visual_Studio_Projects/TestUnixCr
ypt/TestUnixCrypt/UnixCrypt.DLL.
LOG: Attempting download of new URL file:///C:/old_computer/d_drive/dev/Visual_Studio_Projects/TestUnixCr
ypt/TestUnixCrypt/UnixCrypt/UnixCrypt.DLL.
LOG: Attempting download of new URL file:///C:/old_computer/d_drive/dev/Visual_Studio_Projects/TestUnixCr
ypt/TestUnixCrypt/UnixCrypt.EXE.
LOG: Attempting download of new URL file:///C:/old_computer/d_drive/dev/Visual_Studio_Projects/TestUnixCr
ypt/TestUnixCrypt/UnixCrypt/UnixCrypt.EXE.
For openers, I am a dot net (csharp) newbie.
This is where I am at:
1) Created/compiled a dll. The name of the dll is UnixCrypt.dll (wraps a c# impl of unix crypt (i am not the author)).
2) Created/compiled/tested a test-driver executable that references UnixCrypt.dll. All functionality works.
3) Using the sn.exe tool created a public/private key file. In the UnixCrypt assembly manifest I have added the following line:
[assembly: AssemblyKeyFile(@"C:\public_private")]
... where "public_private" is the key-pair file generated from sn.exe.
4) Re-build the UnixCrypt assembly and verify that the assembly is signed using "sn -v" - it returns:
Assembly 'UnixCrypt.dll' is valid
Presumably all is well.
5) Not sure where to go next - this is my question! I want to build the test driver so that is works with (and only with) the signed version of UnixCrypt.dll. The outcome I am attempting to achieve is to create 2 versions of UnixCrypt.dll, one signed and one not signed and have the executable bomb when the non-signed version is substituted for the signed version. I am not sure how to build this dependency into the executable. I tried the following:
csc /t:exe TestUnixCrypt.cs /lib:<path_to_lib> /reference:UnixCrypt.dll
This builds fine, but it bombs at runtime (BTW - in the line above, the dll referenced is the signed version).
The stack trace probably tells me everything I need to know but I am not experienced enough with dot net to make sense of it all. I have put the stack trace at the bottom of this post.
I have spent some time looking through the sdk docs as well as msdn - I found some good answers on some points, some good confusion on others.
Any help here is appreciated. I need some help figuring out how to build the executable such that is depends on the signed assembly and only works with the signed assembly.
Thanks.
cporter
##########################################################
Unhandled Exception: System.IO.FileNotFoundException: File or assembly name UnixCrypt, or one of its depe
ndencies, was not found.
File name: "UnixCrypt"
at SomeCo.TestUnixCrypt.Main(String[] args)
=== Pre-bind state information ===
LOG: DisplayName = UnixCrypt, Version=1.0.931.34461, Culture=neutral, PublicKeyToken=7734614b473eaaae
(Fully-specified)
LOG: Appbase = C:\old_computer\d_drive\dev\Visual_Studio_Projects\TestUnixCrypt\TestUnixCrypt\
LOG: Initial PrivatePath = NULL
Calling assembly : TestUnixCrypt, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: Application configuration file does not exist.
LOG: Publisher policy file is not found.
LOG: Host configuration file not found.
LOG: Using machine configuration file from c:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\config\machine.co
nfig.
LOG: Post-policy reference: UnixCrypt, Version=1.0.931.34461, Culture=neutral, PublicKeyToken=7734614b473
eaaae
LOG: Attempting download of new URL file:///C:/old_computer/d_drive/dev/Visual_Studio_Projects/TestUnixCr
ypt/TestUnixCrypt/UnixCrypt.DLL.
LOG: Attempting download of new URL file:///C:/old_computer/d_drive/dev/Visual_Studio_Projects/TestUnixCr
ypt/TestUnixCrypt/UnixCrypt/UnixCrypt.DLL.
LOG: Attempting download of new URL file:///C:/old_computer/d_drive/dev/Visual_Studio_Projects/TestUnixCr
ypt/TestUnixCrypt/UnixCrypt.EXE.
LOG: Attempting download of new URL file:///C:/old_computer/d_drive/dev/Visual_Studio_Projects/TestUnixCr
ypt/TestUnixCrypt/UnixCrypt/UnixCrypt.EXE.