managed c++ strong name/signing - managed-c++

How can I sign a managed c++ dll with a .pfx file??
Or is there a way to include the unsigned managed c++ dll in a signed c# project?
I realy dont need a signed dll I just need VS to stop giving me the Error "Referenced assembly 'SlimDX' does not have a strong name." in my c# project that must be signed.

If you are building the dll, there is a post build step in VS that will allow you to run the signing utility. Check out this link (for .Net 4.0, there are other versions available from the page)
http://msdn.microsoft.com/en-us/library/xc31ft41.aspx
On another note, I don't think you will be able to sign your dll and include an unsigned dll, so you will either have to sign the C++/CLI dll or not sign yours.

Related

Dll is not loading in ASP.net Web Api 2.0

I really need someone help. I have a ASP.Net Web Api 2.0 project and I am stuck on loading a Dll into my project. Here are the details:
The loading Dll is written in C++, then there is a .Net wrapper WrapperA, then there is another project ProjectA in which we call .Net WrapperA, then there is Web Api calling ProjectA.
The error message I am getting is:
Managed Debugging Assistant 'PInvokeStackImbalance'
Message=Managed Debugging Assistant 'PInvokeStackImbalance' : 'A call to PInvoke function 'CRM.Crypto!CryptOnAPI_Lib.CryptOnAPI::LoadLibrary' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.'
The LoadLibrary() function is defined in WrapperA as
[DllImport("kernel32.dll", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr LoadLibrary(string dllToLoad, IntPtr hFile, uint dwFlag);
In web.config file, I have also mentioned this configuration as well
<hostingEnvironment shadowCopyBinAssemblies="false"/>
I have tried to put all dlls in System32, inetsvr, IIS express folders, but nothing is working. Please note, I have a test application which is a Win Form application to test the dll, and dll is loading perfectly in that application.
I have placed all dlls in bin folder of the web API project. If I remove the dlls from bin folder, I get the same error message as mentioned above.
Please help :(
Found the solution of my problem. Still I am not able to debug with win32 dll but when deployed to IIS server, it is working fine. Solution is, place the Dlls in one of the following folders:
C:\Windows\System32\inetsrv
C:\Windows\SysWOW64\inetsrv
The win32 dll will load in the Asp.Net Api.
Cheers

how to register asphttp.conn component

I need to do enhancements to an classic asp application which uses AspHTTP.Conn.
I am trying to set the application on my system.
I have the dll, but not sure how to install and set up it on my system.
Can you please help with the steps to register the AspHTTP dll on my system.
Did you check AspHTTP dll documentation?
http://www.serverobjects.com/comp/asphttp3.htm
Never mind.
Answer is:
Steps could be vary, depending on library (sorry, i never used before AspHTTP dll) and on version of IIS and of course version of Operation System.
In general steps for any library are
Step 0) find proper folder where you going to store your DLL.
if DLL required only for 1 web site (let's say for "Web01" web site only), I usually keep them in folder like "X:\InetPub\Web01\Dll\"
Step 1) regsvr32 YourDLL.EXE
if you have 64 bit OS and 32 bit library (DLL) then you should run C:\Windows\SysWOW64\regsvr32.exe.
if you have 64 bit OS and 64 bit library (DLL) then you should run C:\Windows\System32\regsvr32.exe.
Step 2) depending on folder, where you store your DLL. if you store DLL in Windows\systemXX folder, then may be you should skip this step. Otherwise perhaps will be needed to add read & execute permission to this DLL file for user which are running your web site or application pool -- it's depending on IIS version you are using and authentication way you are using for your web site. (i always create separated users. so, for my "Web01" web site user name will be like "IUSR_Web01".
Step 3) perhaps in IIS (in IIS 6.0) will be required to add this DLL to "Web Service Extension" with Status = Allowed.

ASP.NET Website is not longer working after the latest Windows Updates

Our ASP.NET website uses some external assemblies like AjaxControlToolkit.dll, AjaxMin.dll, DocumentFormat.OpenXml.dll and some more.
They are registered in the References-Node. All worked fine, but after the latest windows Update, I got the following error:
Could not load file or assembly 'AjaxControlToolkit' or one of its dependencies. Strong name signature could not be verified. The assembly may have been tampered with, or it was delay signed but not fully signed with the correct private key. (Exception from HRESULT: 0x80131045)
If I check the AjaxControlToolkit.dll with the tool sn.exe, it shows, the dll is valid. I have also tried to compile the AjaxControlToolkit with the source code. I have signed it with a strong name and the sn.exe has shown valid. I have tried to install ist to the global assembly cache with the gacutil.exe, but this fail although with the same problem, it has a problem with the strong name, also i have self compiled and signed and so on.
But it is not the problem, because, if i remove the AjaxControlToolkit.dll from the bin folder of the website, running in iis, then, the next dll creates the same error, the AjaxMin.dll could not be loaded.
If I remove the AjaxMin.dll, the DocumentFormatOpenXml.dll created the same error.
We are using Visual Studo 2010 and we have hosted our website in Windows Server 2008 R2.
Kind regards
I was able to resolve this by redownloading the binaries from CodePlex.
http://ajaxcontroltoolkit.codeplex.com/downloads/get/116533

Deploy .net assembly from AOS to each client in AX2012

Once a week I get the new version of .net assembly which I need to deploy to our Axapta 2012 installation. I don't want to copy this dll to axapta client folder on each computer. So I am searching the way to deploy it to AOS and hope it will deploy on each client automatically.
I have found many solution (this is one of them), but all of them works only if I have the source code of this assembly. I don't have. And I can not to 'Add VS project to AOT' and deploy it using VS add-ins.
Is there any way to deploy .net assembly (as compiled DLL) from AOS to each client ?
If you cannot do it using the "Add VS projection to AOT" method, you can use the SysFileDeployment class. This is demonstrated in Joris DG his blogpost here.
On msdn the description of the SysFileDeploymentclass is as follows:
The SysFileDeployment class is used for deploying files from the server to the clients.
On msdn it is also explained how you need to do this.Basically all you need to do is extend this class and point to the files you need to deploy (in your case a dll). You will also have to change the build number of you solution to trigger the deployment.
You can also deploy dll's by adding them to the GAC, as demonstrated here:
Axilicious: AX2012 DLL Deployment and how AX binds DLL’s at runtime
To summarize main differences are:
Using the visual studio properties: it is deployed to a folder specific to that user (so a different folder for each user) at the moment it is needed
Using SysFileDeployment: it is copied to the client bin folder, a restart of the client is needed (possibly problems when on citrix/terminal services, like Joris suggests in the link you provided?)
GAC: DLL's are stored in the Global Assembly Cache and different versions are stored but you need to provide a mechanism of deploying them yourself
Personally I would try the SysFileDeployment method as it's the standard method MS provide. If you have trouble, you might receive support.

Silverlight - Read version of another assembly in local directory

All,
I need to read version number of an assembly in local directory (My document directory to be exact) in my out-of-browser app w/ elevated trust. I cannot use the Assembly.Load, Assembly.LoadFrom methods because these cannot be used in Silverlight (marked w/ security exception attribute).
I know how to load it File.ReadAllBytes(), but then I need the steps to get my hands on the manifest and get the version number.
lk
You can do it with .NET, but not (directly) with Silverlight.
That's because there is no .NET library (as far as I know) that reads assemblies.
With .NET, you can load the assembly in a separate app domain and get the version there.
If you are really desperate, you can embed a .NET application (an .exe file) in your Silverlight application that gets written out and executed from Silverlight.
I've done that before for a different problem.
Feel free to ask me for some code for either of those issues if you really want to pursue this path.

Resources