Windows Develop Bookmark and Share   
 index > ClickOnce and Setup & Deployment Projects > how do I add unmanaged c dll (not com) to a clickonce application and have it work on vista?
 

how do I add unmanaged c dll (not com) to a clickonce application and have it work on vista?

I have a clickonce application that uses some unmanaged c dll that are not com. I have been creating the clickonce appliaction using I copy all the files that are needed to be installed into a folder. This includes all of the .net assemblies and the c dlls

1. run mage.exe to create the application manifest.
2.make some changes to the created manifest to add an icon to the manifest.
3.sign the application manifest.
4.run mage exe to create the deployment manifest.
5 sign the deployment manifest.

On xp whenI run the clickonce install in everything works as expected.
On Vista when I runvia clickonceI have problems loading the unmanaged dlls.
If i just copy thefiles to a folderin vista everything works as expected.

on xp if i look at the installation folder all of the files and the exe and the unmanaged dlls end up in the same folder.
on vista if i look at the installation foldermany folders are created my unmanaged dlls are not in the same folder as the exe.

What do i need to add to the application manifest to make this work?
Thanks for your Help!!!







stewart johnson  Monday, September 21, 2009 3:28 PM

So just to make sure I get it -- if you include them in the ClickOnce deployment, it doesn't work. If you just copy t hem over there, it does, right?

I have an idea you can try.

Zip up the dll's and add the zip file to your project. Deploiy the zip file but not the original dll's as separate files.

Have your application unzip the zip file "in place" before it does anything else.

That would accomplish getting the files there, and remove the dependency in the manifest on the specific dll's.

RobinDotNet


Click here to visit my ClickOnce blog!
RobinDotNet  Friday, September 25, 2009 9:13 PM

You get it.

I have added the dlls to a folder called dll_Resouces that is included in the build.
At application startup I am copying the files to the same folder as the exe. Everything works correctly. LOL.

Clickonce is not really ready for primetime, even in its third iteration.

This will work for now. But there must be a way through some logging findout why it is really failing.

Stewart

stewart johnson  Friday, September 25, 2009 9:22 PM

First of all, why don't you include the dll's in your ClickOnce deployment and use Visual Studio to create the deployment package rather than using mage? Is there some reason for that?

If you want to try that, create a folder under your main project called something like "referenced_dlls" and put the dll's there. Then set the Build Action to "Content" and the "Copy to output directory" to "copy always". The folder with your dll's in it will be included in the deployment. (You might also doublecheck Application Files and make sure they are all set to Include).

To reference them, look in Path.Combine(System.Windows.Forms.StartupPath, "referenced_dlls").

If you can't have them be in a subfolder, put them in the top level and set the property as I have noted.

Now, why are you setting the icon manually? If you go into the properties for your main project and go to the application tab, you can set the icon for your application there.

This should get all of the files into the right place. Give it a try and let me know if it works.

RobinDotNet



Click here to visit my ClickOnce blog!
RobinDotNet  Monday, September 21, 2009 10:56 PM

Hi stewart,

> on vista if i look at the installation folder many folders are created my unmanaged dlls are not in the same folder as the exe.

I would like to know what kind of folders does it created for you. Could you please tell me these folders�names? Are these C assemblies located in the same folder? Are these folders the subfolder of your EXE folder?

And I think Robin’s guide is correct. You can try to do it in Visual Studio and tell us if you meet any problem.

Sincerely,

Kira Qian

Send us any feedback you have about the help from MSFT at fbmsdn@microsoft.com
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework!
Kira Qian  Tuesday, September 22, 2009 5:57 AM
I have tried robbins suggestion of adding the dlls to the project and using the built in publish tab inside of vs2008.
When I install this on vista I get the same behavior that I get with the version I create using mage.exe
In fact the two manifest files are virtually identical except for guids,the extra files that I am adding to the manifest, and the tweaks to get an icon to show in the start menu.

>First of all, why don't you include the dll's in your ClickOnce deployment and use Visual Studio to create the deployment package rather than using mage? Is there some reason for that?

The reason I have been using mage is because after mage builds the application manifest I can tweak some of the settings and then resign the manifest.
I add an icon to the start menu using <description asmv2:iconFile="AudioMan.ico" xmlns="urn:schemas-microsoft-com:asm.v1" />
I also can add somefiles and to the directory i am running mage on and have them added to the manifest and install.

>I would like to know what kind of folders does it created for you....

If look atthe folder structure of application that has been deployed on vista with click once you will see lots of folders created.

09/21/2009 09:45 PM <DIR> bass.net_b7566c273e6ef480_0002.0004_none_86c9d89007d2b1c7
09/21/2009 09:45 PM <DIR> icsh..plib_1b03e6acf1164f73_0000.0054_none_0497891383e08f5c
09/21/2009 09:45 PM <DIR> id3_a91906aada3060a1_0001.0001_none_c987b6258f3d64ac
09/21/2009 09:45 PM <DIR> log4net_1b44e1d426115821_0001.0002_none_1dbdc385b5af585e
09/21/2009 09:45 PM <DIR> manifests
09/21/2009 09:45 PM <DIR> stag...app_a91906aada3060a1_0002.0001_0b96450a8d47955a
09/21/2009 09:45 PM <DIR> stag...exe_a91906aada3060a1_0002.0001_none_f60b97a99d92ce59
09/21/2009 09:45 PM <DIR> stag..ging_a91906aada3060a1_0002.0001_none_3b2256a47dc0606f
09/21/2009 09:45 PM <DIR> stag..imer_a91906aada3060a1_0002.0001_none_f4f3093bb836e4e2
09/21/2009 09:45 PM <DIR> stag..mmon_a91906aada3060a1_0002.0001_none_35f4825d6e0509e9
09/21/2009 09:45 PM <DIR> stag..mmon_a91906aada3060a1_0002.0001_none_6958148d05a4efc6
09/21/2009 09:45 PM <DIR> stag..rver_a91906aada3060a1_0001.0005_none_556429b99b1878c6
09/21/2009 09:45 PM <DIR> stag..sion_a91906aada3060a1_0002.0001_none_d8d4cbb99de03a72
09/21/2009 09:45 PM <DIR> stagesoft_a91906aada3060a1_0002.0001_none_922e0f8cabdf2abe
09/22/2009 08:01 PM <DIR> baby...exe_b7701af2a7dffd56_0001.0001_none_e4db31374c6f1a4a
09/22/2009 08:01 PM <DIR> baby..tion_b7701af2a7dffd56_0001.0001_c4cb2664d6165b10
09/22/2009 08:43 PM <DIR> kbso..ents_3078ae96e1e665f5_0001.0000_none_b97a9b257f96e2cc
09/22/2009 08:43 PM <DIR> magi..rary_3a6eb82f876a49bc_0001.0007_none_10a4c18ba997cb0d
09/22/2009 08:43 PM <DIR> stag...exe_c8e816d4265a06d1_0001.0000_none_f851d89c4c055cfa
09/22/2009 08:43 PM <DIR> stag..ging_a91906aada3060a1_0002.0001_none_3b224cd47dc16fb9
09/22/2009 08:43 PM <DIR> stag..k.ui_a91906aada3060a1_0002.0001_none_30a38c393e642e7d
09/22/2009 08:43 PM <DIR> stag..mmon_a91906aada3060a1_0002.0001_none_69580abd05a5ff10
09/22/2009 08:43 PM <DIR> stag..oman_a91906aada3060a1_0001.0004_none_5e18b216a705109a
09/22/2009 08:43 PM <DIR> stag..rols_a91906aada3060a1_0002.0001_none_7d514cccd54a1ad7
09/22/2009 08:43 PM <DIR> stag..sion_a91906aada3060a1_0002.0001_none_d8d4c1e99de149bc
09/22/2009 08:43 PM <DIR> stag..tion_c8e816d4265a06d1_0001.0000_cc9d9cfd76325265
09/22/2009 08:43 PM <DIR> stagesoft_a91906aada3060a1_0002.0001_none_922e05bcabe03a08

There is a folder stag..tion_c8e816d4265a06d1_0001.0000_cc9d9cfd76325265 that contains
all of the assemblies including the c dlls.

Almost allof the files have 2 other files with the same name as the .net dll but with different extensions like:
09/21/2009 09:45 PM 2,420 ICSharpCode.SharpZipLib.cdf-ms
09/21/2009 09:45 PM 143,360 ICSharpCode.SharpZipLib.dll
09/21/2009 09:45 PM 825 ICSharpCode.SharpZipLib.manifest
These extra files were not in the publish folder created using the publish wizard.

There is another folder stag...exe_c8e816d4265a06d1_0001.0000_none_f851d89c4c055cfa that also contains the c dlls that i am trying to use, an icon file, and some xml files that were labeled content in vs2008.

I am going to try and manually copy my dlls around and see if i can get it to work. If you have any other ideas please let me know.

Thanks for your help!


Stewart

stewart johnson  Wednesday, September 23, 2009 2:39 AM

Do you just have a bunch of ClickOnce applications, or is that not the top folder under the two obfuscated folder names in the ClickOnce cache?

Sort it in descending order by date and find the one for your application, probably something like xxx....tion_

When you find that folder, double-click on the exe. Does the application run? Are all of the dll's there?

When you added them to the project, did you set the build action and copy options correctly? Did you go into the application files dialog and make sure they were all marked as Include or Include(Required) ?

RobinDotNet


Click here to visit my ClickOnce blog!
RobinDotNet  Wednesday, September 23, 2009 10:47 AM
There are 2 applications in the top folder.
The build action and copy options are all correct and they are all marked as include in applications file dialog.

I will try your suggestions about trying to run from the folder and let you know.

thanks,

stewart
stewart johnson  Wednesday, September 23, 2009 3:36 PM
Cool. If it doesn't run when you double-click on the exe, check and see if the assemblies are in that folder. If they're not, you're missing something in your deployment.

RobinDotNet
Click here to visit my ClickOnce blog!
RobinDotNet  Wednesday, September 23, 2009 6:13 PM

Ok I have tried to run the application directly from the folder in the apps path. The application behaves the same way that it does when launched via clickonce.
If I rename the exe.manifest file to something else and launch the application from this folder it works as expected.
It looks like some kind of security problem.

The application is set for full trust in the security page.

I have included the begining of manifest file below.

Any Ideas?

<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly xsi:schemaLocation="urn:schemas-microsoft-com:asm.v1 assembly.adaptive.xsd" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" xmlns="urn:schemas-microsoft-com:asm.v2" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:co.v1="urn:schemas-microsoft-com:clickonce.v1">
<asmv1:assemblyIdentity name="StageSoft.AudioMan.exe" version="2.1.3223.7463" publicKeyToken="a91906aada3060a1" language="neutral" processorArchitecture="msil" type="win32" /><description asmv2:iconFile="AudioMan.ico" xmlns="urn:schemas-microsoft-com:asm.v1" />
<application />
<entryPoint>
<assemblyIdentity name="StageSoft.AudioMan" version="1.4.2223.7464" publicKeyToken="A91906AADA3060A1" language="neutral" processorArchitecture="msil" />
<commandLine file="StageSoft.AudioMan.exe" parameters="" />
</entryPoint>
<trustInfo>
<security>
<applicationRequestMinimum>
<PermissionSet Unrestricted="true" ID="Custom" SameSite="site" />
<defaultAssemblyRequest permissionSetReference="Custom" />
</applicationRequestMinimum>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!--
UAC Manifest Options
If you want to change the Windows User Account Control level replace the
requestedExecutionLevel node with one of the following.

<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />

If you want to utilize File and Registry Virtualization for backward
compatibility then delete the requestedExecutionLevel node.
-->
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>


Thanks


Stewart

stewart johnson  Thursday, September 24, 2009 1:58 AM

Hi Stewart,

Thank you for posting me the detail information.

> It looks like some kind of security problem.

When your application needs to call unmanaged code (C or Win32 APIs), it does need more permissions than “Zone Default� But the “full trust�is enough to run the app. When I tested it on my computer, calling Win32 APIs return security limitation message. But I can overcome it under full trust condition. So the issue cannot be reproduced at my side.

Do you have any special reason to use ClickOnce? If not, what about thinking of other deployment technology?

Another idea is you can try to deployment your application via MSI. When using MSI, you can let your user decide where they want to install. MSI won’t create that long name folder and place your C assembly into other folder. I think that can avoid the problem. But MSI doesn’t have auto update feature as ClickOnce. So you may take that into consideration.

Reference

Walkthrough: Deploying a Windows-based Application

http://msdn.microsoft.com/en-us/library/k3bb4tfd%28VS.80%29.aspx

Sincerely,

Kira Qian

Send us any feedback you have about the help from MSFT at fbmsdn@microsoft.com
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework!
Kira Qian  Thursday, September 24, 2009 9:47 AM

Kira,

Can he elevate permissions in a ClickOnce application? I thought ClickOnce apps wouldn't do that, because they are install-able with not admin privileges. Does having admin privileges mean they CAN elevate permissions even in a CLickOnce application? Isn't that what it looks like his manifest is trying to do?

Thx,
RobinDotNet


Click here to visit my ClickOnce blog!
RobinDotNet  Friday, September 25, 2009 2:45 AM
Hi Robin,

<trustInfo> Element in ClickOnce application manifest determines the minimum security permissions required for the application to run. That doesn’t mean the user need administrator permission to install the app.

Sincerely,
Kira Qian
Send us any feedback you have about the help from MSFT at fbmsdn@microsoft.com
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework!
Kira Qian  Friday, September 25, 2009 6:16 AM
I have done some more investigation.

As I said before ALL of the files are getting installed to the correct folder in vista.

If I delete the manifest file and run the application using click once or directly everthing works.

If I remove the c dlls from the project, use the publish button to create the click once install it on a vista box and copy the c dll's to the folder, everything works.
hmm... If you open a manifest file, there are two types of xml nodes dependency and file. For each c dll that is added as content to the project a file node is created in the manifest.

I think this has something to do with fact that these dlls should really be added to the manifest as dependencies even though they are not com. I think that vista uac is getting in the way and not allowing the c dlls to interact.

Is there a way to view the uac log in vista?


stewart johnson  Friday, September 25, 2009 1:24 PM

So just to make sure I get it -- if you include them in the ClickOnce deployment, it doesn't work. If you just copy t hem over there, it does, right?

I have an idea you can try.

Zip up the dll's and add the zip file to your project. Deploiy the zip file but not the original dll's as separate files.

Have your application unzip the zip file "in place" before it does anything else.

That would accomplish getting the files there, and remove the dependency in the manifest on the specific dll's.

RobinDotNet


Click here to visit my ClickOnce blog!
RobinDotNet  Friday, September 25, 2009 9:13 PM

You get it.

I have added the dlls to a folder called dll_Resouces that is included in the build.
At application startup I am copying the files to the same folder as the exe. Everything works correctly. LOL.

Clickonce is not really ready for primetime, even in its third iteration.

This will work for now. But there must be a way through some logging findout why it is really failing.

Stewart

stewart johnson  Friday, September 25, 2009 9:22 PM

You can use google to search for other answers

Custom Search

More Threads

• ? in file path for activex control in Registry
• ClickOnce Application Update
• Setup & Deployment -- rerun custom action
• Identifying Compressed drive before deployment using clickonce
• How can i get the install path in the setup project?
• Want to deploy, users install from website.
• MUI in ClickOnce.
• ClickOnce publish needs front page extensions?
• Getting ClickOnce to create a desktop shortcut
• Multi-user install does not work from CD-ROM