<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>C&#43;&#43;CLI on Bits and Pieces</title>
		<link>https://bits.strawjackal.org/tags/c&#43;&#43;cli/</link>
		<description>Recent content in C&#43;&#43;CLI on Bits and Pieces</description>
		<generator>Hugo</generator>
		<language>en-us</language>
		
		
		
		
			<lastBuildDate>Tue, 13 Jan 2009 15:04:17 +0200</lastBuildDate>
		
			<atom:link href="https://bits.strawjackal.org/tags/c++cli/index.xml" rel="self" type="application/rss+xml" />
			<item>
				<title>Tales from the Unmanaged Side – System.String –&gt; char* (pt. 2)</title>
				<link>https://bits.strawjackal.org/116/</link>
				<pubDate>Tue, 13 Jan 2009 15:04:17 +0200</pubDate>
				<guid>https://bits.strawjackal.org/116/</guid>
				<description>&lt;p&gt;A while ago, I &lt;a href=&#34;http://weblogs.asp.net/avnerk/archive/2007/08/28/more-tales-from-the-unmanaged-side-system-string-gt-char.aspx&#34;&gt;posted an entry&lt;/a&gt; about marshalling a managed System.String into an unmanaged C string, specifically a plain char*. The solution I suggested, back in 2007, involved calling Marshal::StringToHGlobalAuto method to allocate memory and copy the string data into it, and then cast the HGlobal pointer into a char*. &lt;/p&gt;  &lt;p&gt;It seems that in Visual Studio 2008 a new way of doing it was added, as part of the new &lt;a href=&#34;http://msdn.microsoft.com/en-us/library/bb384865.aspx&#34;&gt;Marshalling Library&lt;/a&gt;. This library provides a whole set of conversions between System.String and popular unmanaged string representations, like char*, wchar_t*, BSTR, CStringT&lt;wchar_t&gt; and others I am even less familiar with. &lt;/p&gt;</description>
			</item>
			<item>
				<title>Upgrading all projects to .NET 3.5</title>
				<link>https://bits.strawjackal.org/118/</link>
				<pubDate>Sun, 25 May 2008 08:56:14 +0200</pubDate>
				<guid>https://bits.strawjackal.org/118/</guid>
				<description>&lt;p&gt;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&#39;t checked). Works fine for regular C# projects, as well as web projects:&lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;div&gt;   &lt;pre style=&#34;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none&#34;&gt;&lt;span style=&#34;color: #0000ff&#34;&gt;For&lt;/span&gt; &lt;span style=&#34;color: #0000ff&#34;&gt;Each&lt;/span&gt; proj &lt;span style=&#34;color: #0000ff&#34;&gt;As&lt;/span&gt; Project &lt;span style=&#34;color: #0000ff&#34;&gt;In&lt;/span&gt; DTE.Solution.Projects&#xD;&#xA;   &lt;span style=&#34;color: #0000ff&#34;&gt;Try&lt;/span&gt;&#xD;&#xA;       proj.Properties.Item(&lt;span style=&#34;color: #006080&#34;&gt;&#34;TargetFramework&#34;&lt;/span&gt;).Value = 196613&#xD;&#xA;       Debug.Print(&lt;span style=&#34;color: #006080&#34;&gt;&#34;Upgraded {0} to 3.5&#34;&lt;/span&gt;, proj.Name)&#xD;&#xA;   &lt;span style=&#34;color: #0000ff&#34;&gt;Catch&lt;/span&gt; ex &lt;span style=&#34;color: #0000ff&#34;&gt;As&lt;/span&gt; Exception&#xD;&#xA;       Debug.Print(&lt;span style=&#34;color: #006080&#34;&gt;&#34;Failed to upgrade {0} to 3.5&#34;&lt;/span&gt;, proj.Name)&#xD;&#xA;   &lt;span style=&#34;color: #0000ff&#34;&gt;End&lt;/span&gt; &lt;span style=&#34;color: #0000ff&#34;&gt;Try&lt;/span&gt;&#xD;&#xA;&lt;p&gt;&lt;span style=&#34;color: #0000ff&#34;&gt;Next&lt;/span&gt; proj&lt;/pre&gt;&lt;/p&gt;</description>
			</item>
			<item>
				<title>Another minor C#/C&#43;&#43; difference - adding existing files</title>
				<link>https://bits.strawjackal.org/124/</link>
				<pubDate>Sun, 28 Oct 2007 14:35:24 +0200</pubDate>
				<guid>https://bits.strawjackal.org/124/</guid>
				<description>&lt;p&gt;Another minor detail that bit me for a few minutes today. I&#39;m posting this so I&#39;ll see it and remember, and possibly lodge it in other people&#39;s consciousness.&lt;/p&gt; &lt;p&gt;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. &lt;/p&gt;</description>
			</item>
			<item>
				<title>Unmanaged deployment is a true DLL Hell</title>
				<link>https://bits.strawjackal.org/131/</link>
				<pubDate>Wed, 29 Aug 2007 23:16:07 +0200</pubDate>
				<guid>https://bits.strawjackal.org/131/</guid>
				<description>&lt;p&gt;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&#39;ll try to list a few, with their causes and (probable) solutions:&lt;/p&gt; &lt;p&gt;1) .NET assemblies are usually very loose in what they&#39;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&#39;t have to rebuild and reversion everything every time. However, if my C# A.DLL has a reference to my CPPCLI.DLL v1.0.0.0, and I then put CPPCLI.DLL v1.1.0.0, I&#39;ll get an exception saying the referenced DLL wasn&#39;t found. Annoying.&lt;/p&gt;</description>
			</item>
			<item>
				<title>More Tales from the Unmanaged Side - System.String -&gt; char*</title>
				<link>https://bits.strawjackal.org/132/</link>
				<pubDate>Tue, 28 Aug 2007 16:08:50 +0200</pubDate>
				<guid>https://bits.strawjackal.org/132/</guid>
				<description>&lt;p&gt;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&#39;t.&lt;/p&gt; &lt;p&gt;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.&lt;/p&gt; &lt;p&gt;Second thought was to go to the System.Runtime.InteropServices.Marshal class and see what it had for me. I found two contenders:&lt;/p&gt;</description>
			</item>
			<item>
				<title>A C# coder in a C&#43;&#43;/CLI world, part 1</title>
				<link>https://bits.strawjackal.org/133/</link>
				<pubDate>Tue, 28 Aug 2007 13:48:50 +0200</pubDate>
				<guid>https://bits.strawjackal.org/133/</guid>
				<description>&lt;p&gt;Recently I&#39;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&#39;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&#39;ll try to go over some pitfalls and insights I&#39;m having during the visit. This is the first:&lt;/p&gt;</description>
			</item>
	</channel>
</rss>
