I am trying to write a code editor in WinRT that will make the Surface RT and Surface 2 a viable device for people who write code using Visual Studio by bringing light weight code editing functionality to Windows RT in a Windows Store app (No debugging, obviously, just editing files in SkyDrive that are used on a real PC in Visual Studio). This app would include intellisense-like features as a key functionality, and to do this, I would have the user browse to all of the .DLL and .EXE files that their project references. Outside of WinRT, this is relatively simple, but I don't see how to load an assembly from a DLL in WinRT. Is it possible? Remember, I just need to get the string data containing the classes and namespaces contained within the library, and the names of the members of those classes and nothing more.
If it's not possible, it's a shame that a developer like me has to be stopped by all of the restrictions in Windows RT. I am, after all, just trying to write a virus by loading external DLLs and reading the names of the classes, and not running any of the code (sarcasm alert).
Would you really need the dll's and exe's or do you just need the data that will be used? Why not extract the data that your application will use and store that information instead of the complete dll's and exe's?
Related
I am trying to use a C++ DLL in C# Windows Store app. I included the DLL file as Content with Copy Always option, in a project directory (which should map to an installation directory upon installation).
This works fine on a Desktop without a problem.
Based on what I have researched online, I cannot figure out why this method doesn't work for Windows Phone Emulator and Device.
Worth pointing out that the DLL is updated to the appropriate architecture (x64, x86, arm) with VS2015's Pre-build event command.
Some unsuccessful attempts:
I attempted using LoadPackagedLibrary in App Initialization just in case the DLL was not being loaded in time but didn't help (also meant messing up with DllImport I could do without!).
I would have thought Package.appxmanifest is where such dependencies are declared (or hinted) but couldn't find much mileage with this approach either.
Am I missing [something obvious] for an unmanaged DLL included as Content?
I've this feeling that this should be straight-forward 'cos many developers must have done this but can't figure or find a how-to example. Help!
I am a Visual Studio 2013 Newbie who is trying to figure out how to build a C DLL in Visual Studio and then invoke the functions exported by the C lib from within a C# app. I've got everything building, but I cannot figure out the proper way of getting the DLL included with the app build so that it will actually load properly when using [DLLImport()]. I currently get a System.DllNotFoundException when attempting to invoke a function from the library from within my C# class.
I have setup a VS 2013 solution which contains the following projects:
HelloWorldLib.Shared :
Shared project that contains the .cpp and .h files for the DLL
HelloWorldLib.Windows :
Win 8.1 C++ project that references the shared project and builds the DLL for Win 8.1
MyApp-Win.Windows :
C# project for Win 8.1 that wants to make use of the HelloWorldLib.Windows.dll produced by the HelloWorldLib.windows build
I have been looking over many SO questions and answers. For instance, I think my question is similar to this one, which doesn't appear to have been answered in any useful way:
Interop, Native DLL and Visual Studio build process
Some of the other answers suggested adding a file reference to the DLL, but how would I do that and keep the proper Debug/Release versions? Given that all of these projects are being built within the same solution, and there are build dependencies between them, it feels like there should be a straightforward way to set this up.
BTW, I am using the shared project setups, as my ultimate goal is to figure out how to get this all working with Xamarin to target iOS, Win, Win Phone, Mac and Android. So that we can use a common C/C++ layer for our high performance requirement code, and the reference it from the UI layers on the various platforms.
This is a pretty straight-forward problem, easy to identify if you look where the built files end up. The C++ build system has a different strategy than the managed build system. It by default writes the build output to the solution directory's Debug directory. Your C# project however builds to its bin\Debug directory and requires all dependent DLLs to be present there.
So, by default, your C# program can never find the DLL, it is in the wrong directory and Windows doesn't look there. Nor is MSBuild smart enough to discover this by itself, like it can for managed DLLs, it cannot see that you program depends on the C++ DLL.
Two basic ways to work around this:
Change the C++ project's Output Directory setting
Write a post-build event for your C# project that uses xcopy.exe to copy the DLL.
Unfortunately things aren't that easy, at least not yet. I was going to have a meeting with Microsoft C++ team but that got postponed, similar functionality you are after was one of the things on my wishlist (building managed C++/CLI wrappers for Xamarin.iOS and Android).
Currently, if you can, the easiest option is to wrap C++ code inside a DLL that exposes C interface. Then build it with XCode and Android NDK. If you can't then the next option is to create Objective-C binding project that wraps the C++ code inside Objective C classes for iOS. For Android either create Java wrapper or use SWIG. Both of these options are cumbersome which is why C API should be the first choice you investigate.
I know it's not the answer you were hoping for but reusing C++ code is way more complicated than reusing C# or even C.
I am trying to use Slicer dll reference to convert images to a video file, but I am having a problem with adding the reference to my Windows Phone project, I get the error
Reference cannot be added to l because it was not built using the Windows Phone runtime. Windows Phone projects will work only with Windows Phone assemblies.
I searched and found this link where it's mentioned to
Create a new class library for Silverlight for Windows Phone 7
I don't know if I am creating the class project right but it's not working I get the same errors as with the win phone project, can't install .dll, does anyone know how I can create the class library correctly without this error?
Or even if it is possible to use Splicer with windows phone 7 & 8?
Thanks for your help.
As far as I know, Splicer isn't built to work on Windows Phone. While it seems like it would make sense that general .NET libraries would work on a .NET compatible platform like WP7 and WP8, that's not necessarily the case. (a little outdated, but here: http://dotnet.dzone.com/articles/not-every-library-will-work)
You could always check out Splicer from Codeplex, but you'd probably have to do a non-trivial amount of modification to get it to work for your project. I'd surmise you could maybe pull it off by just modifying the class libraries in the solution, but there are probably pitfalls included with that. Worse comes to worse, you could take all the source files, copy them into a new Windows Phone library project, and then resolve all the build errors. Either way, it'll involve some work.
I am new to windows phone. i need to deploy two xap files as one application to device. In fact we can say that i need to merge them. These two application should also interact between them. Can it be doable?
EDIT:
Firstly my question was the question above. But i understand that there is no way to launch another application inside the other one. So i think it would be meaningless to merge them if ever we could have done so. So i edited the question:
I have one applications xap file and i need to develop another application which should call this applications first page when user clicks some button on develeping application.
The questions are:
Can i import xap file into developing project or xap file of it?
Can i import xap file as a library project to developing project?
Can it be done without source code of the already developed application so that i can interact it from developing application?
Can i import xap file into developing project or xap file of it?
No, WP7 app can't have nested xap files - such app will fail the certification in the Marketplace.
Can i import xap file as a library project to developing project?
If you can unpack the xap file (as it is a zip folder) - you can use dlls to add them as references. So, you can execute some code from that application.
Can it be done without source code of the already developed application so that I can interact it from developing application?
You can try to decompile that app (using dotPeeker for example) if it's legal in your country.
But in general the answer is no.
you cannot just import pure xap into your project and use it
you can extract files from the xap and reference them as a library, call methods in it, etc.
you can also disassemble these libraries into source code and use it in your app directly. For simple projects it might be quite easy, for complex it might not possible at all - the dlls might be obfuscated and you might not be able to use them at all.
As others have said, the answer to these questions in general is "no", but regarding your question "Can i import xap file as a library project to developing project?" - the answer is "maybe, but not directly". If you are just trying to call functions from a DLL that's in the 2nd xap file, then you might be able to extract the DLL from the XAP (by first changing the xap's filename extension to .zip) and then reference that DLL in your project. Of course, if you have the source code for that 2nd xap file, then you're probably better off building the DLL into your VS solution as a separate source project and then referencing that VS project from the calling assembly.
I have a .net 3.5 application and i'd like to make it portable.
It's simple and runs perfectly, i've sent the .EXE + .DLL's to some friends and it works as intended when running the exe with the .DLL's and the .ICO (that i have used in it) along in the same folder.
What i want is simple: creating a single EXE file that cares the dll's, image and whatever-i-want along with it without being a setup, and requiring no installation. (a.k.a portable)
I may consider migrating it to .net 2.0 if needed, i don't use any 3.5-only functionality, in fact, i'm not really sure why i'm using 3.5 (i'm new at programming anyhow)
I'd like any tips, links, or an explanation on how to do it, because it's really annoying sending .rar's to my friends and telling them to extract and run the .exe among all "weird files" as they call (besides, not everyone has extension display in folders, so it's a nightmare)
(I have searched in StackOverflow, and haven't found any questions that answer what i'm asking, the only one that I found to be like it ended up in a discussion of framework availability in windows machines, language choosing and no good answers.)
You can use ILMerge to merge all the assemblies into your executable. I'd expect your icon to already be an embedded resource - or you should at least be able to create it as such.
Targeting .NET 2.0 would make the application more widely portable in that it would just work on machines which only have .NET 2.0 installed - but I don't know what the proportions look like for 2.0 vs 3.5 deployment, and more importantly they may well not be the same as the proportions for deployment out of your target audience.
You can add any data (assemblies, icons, etc) required by your application as resources or embedded files.
Either use the resource editor, or if you want to get your hands dirtier, you can add any file by just right clicking on the project in the solution explorer and doing an "add existing item", getting properties on the file and setting Build Aciton to "Embedded Resource".
Resources like Icons can just be used directly - as in DrawIcon(Properties.Resources.MyIcon)
Data files can be loaded using Application.GetManifestResource (and related methods) to get a stream to load from. For example, for an assembly, you can use Assembly.Load() directly from the manifest resource stream for your resource.
You could also use Xenocode to Virtualize Your Applications. Specifically Xenocode Postbuild for .NET.