Browse by Tags
All Tags »
C++/CLI (
RSS)
A simple macro to change the Target Framework for a project from .NET 2.0 to .NET 3.5, hacked together in a few minutes. This will fail for C++/CLI projects, and possibly VB.NET projects (haven't checked). Works fine for regular C# projects, as well as web projects: For Each proj As Project In DTE.Solution.Projects Try proj.Properties.Item( "TargetFramework" ).Value = 196613 Debug.Print( "Upgraded {0} to 3.5" , proj.Name) Catch ex As Exception Debug.Print( "Failed...
Another minor detail that bit me for a few minutes today. I'm posting this so I'll see it and remember, and possibly lodge it in other people's consciousness. Using Visual Studio 2005, adding an existing .cs file to a C# project will cause a copy of that file to be created in the project directory. If I want to link to the original file, I need to explicitly choose Add As Link from the dropdown on the Add button. C++ projects, however, have the opposite behavior. Adding an existing item...
By a staggering margin, most of my problems integrating C++/CLI code into my C#-based project has been deployment problems. Without fail, every integration or test deployment will be plagued with inexplicable problems. I'll try to list a few, with their causes and (probable) solutions: 1) .NET assemblies are usually very loose in what they'll bind to. If I compiled A.DLL against B.DLL version 1.0.0.0, it will still work if it can only find B.DLL version 1.2.0.0. I don't have to rebuild and reversion...
Today, I had a very tight deadline to achieve a very simple task: pass a managed .NET string to an API function that expects a null-terminated char*. Trivial, you would expect? Unfortunately it wasn't. My first though was to do the pinning trick that I mentioned in my last post, but in this case I needed my resulting char* to be null-terminated. Second thought was to go to the System.Runtime.InteropServices.Marshal class and see what it had for me. I found two contenders: 1) Marshal::StringToBSTR...
Recently I've found myself stumbling around some C++/CLI code. C++ is a language which I learned years ago and never really worked with seriously, so I've been cursing and moaning as I worked. Strange for me to go back to a (partially) unmanaged environment now, with all sorts of assumptions that I have proven to be false. I'll try to go over some pitfalls and insights I'm having during the visit. This is the first: The Garbage Collector really spoiled me. I'm not talking about deleting what I instantiated...