I have followed this example on how to mix C# and C++ code in single assembly and all compiles fine. But all this is from the developer command prompt. I want to put all this in one Visual Studio solution and can't succeed. Does anybody know how to do that? (I am still very inexperienced with Visual Studio)
I have found several articles about this, but all give examples from the command prompt. This SO answer even recommends not doing this at all, not sure why?
Also, many of those articles talk about creating a managed DLL (using dllexport/dllimport, but I need to link the obj/lib files directly in the same C# assembly.
Note: The reason I need to do this, is to add a licensing static library to my C# desktop application project. The library is written in C/C++ and is already used in my back-end, I would like to use the same logic for the front-end. Loading the library as a DLL would defeat the purpose since anybody could just change it for a fake one. Therefore linking it in the same assembly is essential.
Related
I have one c# Application which i have only published Application in IIS and i don't have the original code with me.
we have to make some changes in one (.cs) file which is dependent on entire application and dlls.
Is it possible to convert the Application and make some changes and publish again.
I did run into this situation before where client is only having published code and I need to enhance a product.
For those , I decompiled published DLLs using Telerik's JustDecompile as I found it more mature and accurate than DotPeek and Reflector.
Few of the things will still not work after decompilation and that is obvious so you will need to manually fix those.
You may also remove few of the layers by introducing your own layer to avoid all DLL decompilation , but for that you need to understand decompiled code.
I hope that it will help you in running project.
Thanks,
Background
I'm currently doing a benchmark of solutions to convert java code to c#
We have a fast evolving java software and wan't to port some low level (not ui) apis with a tool, because maintaining all changes between versions could prove really tiresome...
Anyway, I've been trying to use Sharpen, as I heard it's a pretty wicked tool used by some mono "freaks" to keep some versions of their tools in check.
What I did
For this purpose, I tried several tutorials I found on internet, the easiest to understand being http://www.pauldb.me/post/14916717048/a-guide-to-sharpen-a-great-tool-for-converting-java
As the link he gives for a pre-build sharpen plugin is now broken, I build my own version of the plugin using sources and instructions found here : https://github.com/xamarin/XobotOS/
Result
The plugin build perfectly, and is installed in my eclipse folder. But when I try to run the ant script after setting everything up, I get an error :
java.lang.RuntimeException: Application "sharpen.core.application" could not be found in the registry.
Conclusion
Well. I'm lost here.
I have no idea what that means.
I'm using Windows 7 64bit
I'm using Eclipse 3.7
I'm using java 6 sdk 64 bit
If anyone ran into this and has a solution... That be helpful.
Thanks in advance.
Initially I tried the same approach as you did, with the same result. But if you follow the instructions in the README.build file, section Setting things up, you should be able to launch a secondary Eclipse applications with the sharpen.core and sharpen.xobotos plug-ins included.
You could then import your Java project subject to conversion into the secondary Eclipse app, provided that you have included a Sharpen Xobot builder command and nature into your project file, like this .project file in the XobotOS/android folder. I edited the .project file manually before importing the project, but I assume you can also configure this from within Eclipse?
The configuration files provided by Paul Du Bois are not applicable, instead you will need to copy and edit the converter-config.xml file from the XobotOS/android folder. This file in turn references a file in the app sub-folder, which probably also needs to be copied and edited.
This is basically as far as I have been able to take it until now. I have been able to edit the configuration files to enable the converter to run, but at this point I have only been able to generate C# stubs. If you or someone else manages to take this even further, I would be happy to learn how to generate real C# files using the XobotOS Sharpen converter.
UPDATE
Asked Miguel de Icaza if there were any instructions for converting arbitrary Java projects using the XobotOS Sharpen version. He responded that there are many hard-coded details in this version that makes it difficult to apply to arbitrary projects. At this stage he recommends Lluis Sanchez' Sharpen version to be used instead.
BTW, the NGit library has been moved to here. You will find a fully functional sharpen plug-in for Eclipse in the gen/plugins sub-folder.
UPDATE MAY 17
Note that you need to have the Plug-in Development Environment software installed in Eclipse to be able to build and run the plug-in projects. IF you are running Eclipse IDE for Java (SE) Developers, you need to extend it with the PDE software.
Forgive me for asking a common question, but I couldn't quite get what I needed from what I found so far.
First question - SQLite. I am using this DB as in my C#.NET 3.5 windows service and it works great, I was looking for a portable solution, because I would like port my service to a linux daemon etc, using Mono, which seems to support it. However, I am not sure how to implement this. I had thought the dll was compatable, but it seems there is a seperate dll for Mono/.NET which I should have expected. Does this mean I need to seperately code/compile for each platform or is there something that would allow me use of SQLite with the same code on various platforms? I have encountered this a few times in my searches, csharp sqlite, a "reimplementation". To be honest, this is quite new to me, is it of use? The Mono SQlite page says that they Mono.Data.Sqlite code is based on System.Data.SQlite and goes on to say...
"We have chosen this way as means to
provide a migration path for
developers using SQLite in their .NET
applications"
Are they referring to creating a new, seperate binary? Or could I run my code as is with some adaptation?
Second question - GUI. As far as I can tell the two main options for cross platform dev in .NET would be GTK# and Winforms. Again however, its the specifics of implementation that are a bit hazey. Can I create a win forms GUI in visual studio as I normally would then easily migrate this using mono? Or should I develop this in something like X-Develop or MonoDevelop?
Many thanks for your advice/patience :D
To help out a little bit here I used the full mysql dll file that was provided and I was able to compile my program on windows using visual studio, and then deploy it to Linux without changing anything(except the case of the mysql dll file, which is kind of annoying you'll see what I mean at some point).
Also from what I've heard winforms isn't totally supported by mono yet, but I may be wrong. I haven't done a gui cross platform yet, but I would test winforms first, just so you could develop it in visual studio, and if that doesn't work I think GTK should be fine.
You just need to make sure that the dll's are compiled for .net 3.5 or below and you should be fine(90% of the time).
Check this out here, http://www.mono-project.com/MoMA and also the link that chris provided.
i am working project in c# Visual studio 2009,i am using c++ dll in my project and also i call that dll through my function . In my system the project run successfully.but in other system not in single system more than system i checked it shows exception like unable to load dll. i am check that dll in dependency walker it shows msvcr71.dll is missing.how i get this.?i need better solution for this
The problem is that your native C++ DLL depends on the library msvcr71.dll. This is not part of the standard windows installed hence you must take some action to get it onto the target machine.
The simplest way to do this is to just copy the DLL around with your application. The following KB article covers this.
Documentation on msvcr71.dll
http://msdn.microsoft.com/en-us/library/abx4dbyh(VS.71).aspx
You're probably missing something in your installation of the SDK (or Visual Studio). I would recommend a Repair or Reinstall.
look on msdn for info about redistributables - this tell you what you need to install on a non dev box to make things work
This is not programming related. You are missing a dll file on your target system. Download and put in "windows/System32" and it should run.
I am writing in C#.
How can i find out which methods/functions I can use in an unmanaged dll that doesn't belong to windows?
Exmaple : I have some installed software on my computer, it has a dll, and i want to know what my options are as to creating code to connect to that software?
For native DLL's that you do not have a reference for you can use the dumpbin utility in the Visual Studio SDK to extract the list of exported functions in a DLL.
Dumpbin reference is here: http://msdn.microsoft.com/en-us/library/c1h23y6c(VS.71).aspx
And a CodeProject page giving some additional details on how to use dumpbin in conjunction with finding the correct P/Invoke signatures is here: http://www.codeproject.com/KB/mcpp/usingcppdll.aspx#Retrieve
PInvoke.net is great resource for .NET interop. They list not only the functions available in Windows native libraries, but also the signature you need to use in your .NET code.
use Depends.exe (which comes along with VS).
Depends would display all the exported function that can be invoked from Managed code using Pinvoke.
I read a blog about PInvoke Interop Assistant, which can deal with our own DLLs as well
http://www.codeplex.com/clrinterop/Release/ProjectReleases.aspx?ReleaseId=14120
I would just like to add that if it's a COM assembly, like a VB6 COM component, it can be browsed in the Object Explorer in Visual Studio and that's pretty nice because it breaks everything out for you quite nicely.