I have a website project in asp.net that references a project that has the private key and host key embeded as a resource, how do I reference the private key and host key correctly in the website project?
In other words, the referenced project is called ClientCerts. It contains host key: mykey.text and privatekey.ppk both as embeeded resource.
Now if Im adding a connection string in the website project I am unaware how to refernce the files...
I have tried the Data Connections in the server explorer, but when I click on add advanced properties, and select the private key from storage. The pop up box asks Key Type: File, Resource, Storage. I click resource it opens a dialogue I select the key it says: "Unable to add certificate file. No project selected."
Any help appreciated.
Embedded host key and private key in referenced project
Re: Embedded host key and private key in referenced project
If you want to access these files at design time, please find them on your file system via the Select menu of MySqlConnection Editor (if you add them to your ClientCerts project, the mykey.text and privatekey.ppk files should be available in the root folder of ClientCerts).KW wrote:I have a website project in asp.net that references a project that has the private key and host key embeded as a resource, how do I reference the private key and host key correctly in the website project?
In other words, the referenced project is called ClientCerts. It contains host key: mykey.text and privatekey.ppk both as embeeded resource.
Now if Im adding a connection string in the website project I am unaware how to refernce the files...
If you want to access mykey.text and privatekey.ppk as embedded resources of ClientCerts.exe (or ClientCerts.dll), you can do it at run-time. Please refer to MSDN: http://support.microsoft.com/kb/319292.
This is a designed behaviour. The embedded resource should be embedded to the assembly of your project. Server Explorer doesn't have an assembly to embed the resource files in.KW wrote:I have tried the Data Connections in the server explorer, but when I click on add advanced properties, and select the private key from storage. The pop up box asks Key Type: File, Resource, Storage. I click resource it opens a dialogue I select the key it says: "Unable to add certificate file. No project selected."
Re: Embedded host key and private key in referenced project
Basically, this works:
However, this won't work if I upload my website to a hosting provider. Because the hosting provider in a shared hosting environment doesn't let you fool around in the c drive, ie, browse, read write execute etc. No permissions.
So, what is the syntax for the embedded resource? I have tried:
Where the files are located as a embedded resource using the resx file.
Of course this doesn't work. But I thought this was roughly the idea.
However, this won't work if I upload my website to a hosting provider. Because the hosting provider in a shared hosting environment doesn't let you fool around in the c drive, ie, browse, read write execute etc. No permissions.
So, what is the syntax for the embedded resource? I have tried:
Where the files are located as a embedded resource using the resx file.
Of course this doesn't work. But I thought this was roughly the idea.
Last edited by KW on Tue 10 Aug 2010 18:27, edited 1 time in total.
The correct format of the resource identifier is
where MyAssembly stands for the assembly into which the resource is embedded, and ResourcePath is the complete path to the resource in the project. To determine the assembly name you can, e.g., check the "Assembly Name" field in the properties of the project containing the resource.
Please refer to http://www.devart.com/forums/viewtopic.php?t=16923.
Code: Select all
resource://MyAssembly,%ResourcePath%
Please refer to http://www.devart.com/forums/viewtopic.php?t=16923.
hmmm.
Still can't get this work:
here is my syntax, the project that is referencing the assembly is a website project and I'm not sure if that matters.
ssh private key=resource://ClientCertificate,DsaPrivateKey.ppk;
ssh host key=resource://ClientCertificate,ssh_host_dsa_key.pub;
I get the error, can't find resource. The assembly name I believe is correct.
The assembly .dll is located in the bin directory of the website.
Getting error:
Resource ID ssh_host_dsa_key.pub: resource not found.
The two files located in the ClientCertificate project have build action as Embedded Resource.
Still can't get this work:
here is my syntax, the project that is referencing the assembly is a website project and I'm not sure if that matters.
ssh private key=resource://ClientCertificate,DsaPrivateKey.ppk;
ssh host key=resource://ClientCertificate,ssh_host_dsa_key.pub;
I get the error, can't find resource. The assembly name I believe is correct.
The assembly .dll is located in the bin directory of the website.
Getting error:
Resource ID ssh_host_dsa_key.pub: resource not found.
The two files located in the ClientCertificate project have build action as Embedded Resource.
1. Is ClientCertificate.dll loaded to the process of your web application? For this, please set a break point in your project, run it in the Debug mode of Visual Studio, navigate to the Debug > Windows > Modules window of Visual Studio. Is ClientCertificate.dll there? Also determine the location of the loaded ClientCertificate.dll in this window, and open this loaded assembly in some tool that enables resource viewing (e.g., .NET Reflector) to find out if it really contains the necessary embedded resources.
2. Can you access the keys that are embedded into ClientCertificate.dll in the code from ClientCertificate.dll itself?
3. Tell us the version of your dotConnect for MySQL. You can find it via the Tools > MySQL > About menu of Visual Studio.
2. Can you access the keys that are embedded into ClientCertificate.dll in the code from ClientCertificate.dll itself?
3. Tell us the version of your dotConnect for MySQL. You can find it via the Tools > MySQL > About menu of Visual Studio.
I executed the following code in a windows forms project
var ass = Assembly.Load("ClientCertificate");
var strings = ass.GetManifestResourceNames();
I noticed that my files were correctly showing. I then executed the same code in the website project and noticed they were not in there. The .dll file didn't get updated, I removed the .dll from the website project and readded it. My files then showed up using the previous code and it now works correctly.
var ass = Assembly.Load("ClientCertificate");
var strings = ass.GetManifestResourceNames();
I noticed that my files were correctly showing. I then executed the same code in the website project and noticed they were not in there. The .dll file didn't get updated, I removed the .dll from the website project and readded it. My files then showed up using the previous code and it now works correctly.