Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Compact Framework / March 2008

Tip: Looking for answers? Try searching our database.

PocketPC Deployment Issues

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Markus Ewald - 26 Mar 2008 08:46 GMT
I'm developing a Smart Device application that includes a native C++ DLL
that is used via PInvoke.

All Projects, including the C++ DLL, are contained in a single solution
like this:

  Solution
    MyLibrary.Native (C++ DLL)
    MyLibrary (C# P/Invoke Wrapper)
    MyApplication (C# App)

When I deploy the library to my PocketPC, it copies the binaries of each
project into a separate folder (eg. \Program
Files\MyLibrary.Native\MyLibrary.Native.dll and \Program
Files\MyLibrary\MyLibrary.dll). This means that my P/Invoke wrapper
cannot find the C++ DLL.

Is there a way I can tell Visual Studio to deploy the output of the
other projects into my application's target directory?

I already tried copying the binaries from the other projects into the
output folder of MyApplication using a post-build step, but while this
works flawlessly for C++ projects, C# projects will still only deploy
the files actually produced by the compiler.

-Markus-
Peter Foot - 26 Mar 2008 11:31 GMT
A C# project will copy any .dll files you reference to the output directory
if they are not part of a known distribution package (such as the .NETCF
libraries themselves). If you want to add a resource file or native dll add
it to your project and set the BuildAction property to "Content". Set the
Copy to Output Directory to "Copy if Newer". Now your project will deploy
the native dll to the same folder as your .exe

Regards.

Peter

Signature

Peter Foot
Microsoft Device Application Development MVP
www.peterfoot.net | www.inthehand.com
In The Hand Ltd - .NET Solutions for Mobility

> I'm developing a Smart Device application that includes a native C++ DLL
> that is used via PInvoke.
[quoted text clipped - 22 lines]
>
> -Markus-
Markus Ewald - 26 Mar 2008 12:14 GMT
> A C# project will copy any .dll files you reference to the output
> directory if they are not part of a known distribution package (such as
> the .NETCF libraries themselves). If you want to add a resource file or
> native dll add it to your project and set the BuildAction property to
> "Content". Set the Copy to Output Directory to "Copy if Newer". Now your
> project will deploy the native dll to the same folder as your .exe

Thanks, that's a nice solution!

The only problem with that would be that I cannot easily switch between
Release and Debug builds because I cannot add a link to
MyLibrary.Native.dll in both the bin\x86\Release and bin\x86\Debug folders.

I think I can solve that with a Pre-Build step that copies the C++
output directory from the correct build configuration to some temporary
place from where I can link it into the project.

> Regards.
>
> Peter

Thanks again,
-Markus-
Markus Ewald - 26 Mar 2008 13:36 GMT
Markus Ewald schrieb:
>> A C# project will copy any .dll files you reference to the output
>> directory if they are not part of a known distribution package (such
[quoted text clipped - 6 lines]
> Thanks, that's a nice solution!
> [...]

Well, I got the Release/Debug issue solved by manually inserting a
Condition into the ItemGroup in the .csproj file. Visual Studio seems to
handle it just fine. I'm linking the files directly from the C++ DLL's
target directory, so my build process is now also free of any
Pre-/Post-Build steps =)

The only annoyance is an inconsistency in the behavior of Visual Studio
between .NETCF 2.0 and .NET 2.0 builds:

- if I add a link to MyLibrary.Native.dll into my MyLibrary.dll project
under .NET 2.0, Visual Studio will copy it to the output folder of all
depending projects (in other words, I'll find MyLibrary.Native.dll in
the output folder of MyApplication if MyApplication references MyLibrary)

- if I do the same under .NETCF 2.0, MyLibrary.Native.dll will only be
copied into the output folder of the project containing the link (so
I'll find MyLibrary.Native.dll in the output folder of MyLibrary, but
not in that of MyApplication)

-Markus-
Mark Erikson - 26 Mar 2008 11:44 GMT
> I'm developing a Smart Device application that includes a native C++ DLL
> that is used via PInvoke.
[quoted text clipped - 22 lines]
>
> -Markus-

If you just need to have them in the same directory for debugging and
development, you need to change the "Output files folder" option to
the same location as your main project.  In VS 2005, it's located at
Project > Properties > Devices.

However, Peter Foot is correct that for actual installation and
deployment, you'll want to include a build of the native DLL as a
"Content" file in your main project.  I've got a project that does as
well.

Hope this helps!

Mark Erikson
http://www.isquaredsoftware.com

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.