<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>C# on Marko Apfel</title><link>http://blog.marko-apfel.de/tags/c%23/</link><description>Recent content in C# on Marko Apfel</description><generator>Hugo</generator><language>en-US</language><lastBuildDate>Sat, 20 Oct 2012 17:26:00 +0200</lastBuildDate><atom:link href="http://blog.marko-apfel.de/tags/c%23/index.xml" rel="self" type="application/rss+xml"/><item><title>Entity Framework, Code First: where is the database?</title><link>http://blog.marko-apfel.de/posts/entity-framework-code-first-where-is-the-database/</link><pubDate>Sat, 20 Oct 2012 17:26:00 +0200</pubDate><guid>http://blog.marko-apfel.de/posts/entity-framework-code-first-where-is-the-database/</guid><description>&lt;p&gt;With Entity Framework 5 in Visual Studio 2012 the code first feature could let you come to the question “Where is the automatically created database located?”&lt;/p&gt;
&lt;p&gt;I run in the question after changing the model which throws during the next run this error:&lt;/p&gt;</description></item><item><title>LINQ and ArcObjects</title><link>http://blog.marko-apfel.de/posts/linq-and-arcobjects/</link><pubDate>Wed, 12 Sep 2012 15:20:00 +0200</pubDate><guid>http://blog.marko-apfel.de/posts/linq-and-arcobjects/</guid><description>&lt;h2 id="motivation"&gt;Motivation&lt;/h2&gt;
&lt;p&gt;LINQ (language integrated query) is a component of the Microsoft. NET Framework since version 3.5. It allows a SQL-like query to various data sources such as SQL, XML etc.&lt;/p&gt;
&lt;p&gt;Like SQL also LINQ to SQL provides a declarative notation of problem solving – i.e. you don’t need describe in detail how a task could be solved, you describe what to be solved at all. This frees the developer from error-prone iterator constructs.&lt;/p&gt;</description></item><item><title>xUnit runner eats system diagnostic output</title><link>http://blog.marko-apfel.de/posts/xunit-runner-eats-system-diagnostic-output/</link><pubDate>Mon, 07 Nov 2011 13:28:00 +0100</pubDate><guid>http://blog.marko-apfel.de/posts/xunit-runner-eats-system-diagnostic-output/</guid><description>&lt;h2 id="problem"&gt;Problem&lt;/h2&gt;
&lt;p&gt;When using xUnit and constructs like Debug.WriteLine the &lt;em&gt;DbgView&lt;/em&gt;-tool does not show the written output anymore.&lt;/p&gt;
&lt;h2 id="solution"&gt;Solution&lt;/h2&gt;
&lt;p&gt;Add a new Listener – for example:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-cs" data-lang="cs"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;Debug&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Listeners&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;DefaultTraceListener&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description></item><item><title>"Failure has occurred while loading a type."</title><link>http://blog.marko-apfel.de/posts/failure-has-occurred-while-loading-a-type/</link><pubDate>Fri, 28 Oct 2011 12:08:00 +0200</pubDate><guid>http://blog.marko-apfel.de/posts/failure-has-occurred-while-loading-a-type/</guid><description>&lt;h2 id="motivation"&gt;Motivation&lt;/h2&gt;
&lt;p&gt;During programming suddenly this error (&lt;code&gt;Failure has occurred while loading a type&lt;/code&gt;) was thrown by accessing a artifact of a referenced library.&lt;/p&gt;
&lt;p&gt;In such cases I take the assembly fusion logger &lt;em&gt;fuslogvw&lt;/em&gt; to search for problems of loading assemblies. Sometimes an old version from a not expected folder is binded. But all bindings were correct.&lt;/p&gt;</description></item><item><title>Suppressing Add-in-registration task during build process</title><link>http://blog.marko-apfel.de/posts/suppressing-add-in-registration-task-during-build-process/</link><pubDate>Mon, 16 May 2011 07:17:00 +0200</pubDate><guid>http://blog.marko-apfel.de/posts/suppressing-add-in-registration-task-during-build-process/</guid><description>&lt;p&gt;If you develop ArcGIS Add-ins with Visual Studio under limited permissions you get during the build process an error, that the stuff could not be registered.&lt;/p&gt;
&lt;p&gt;Normally its enough to run one times this build as an admin. Then all needed information are set and also taken for users with limited access.&lt;/p&gt;</description></item><item><title>Differences by pasting formatted text in Word and OneNote</title><link>http://blog.marko-apfel.de/posts/differences-by-pasting-formatted-text-in-word-and-onenote/</link><pubDate>Sun, 02 Jan 2011 08:54:00 +0100</pubDate><guid>http://blog.marko-apfel.de/posts/differences-by-pasting-formatted-text-in-word-and-onenote/</guid><description>&lt;p&gt;By pasting formatted text in Word and OneNote both applications act a little bit different. Meanwhile Word supports RTF-formatting OneNote does not.&lt;/p&gt;
&lt;p&gt;OneNote could only handle HTML-formatting.&lt;/p&gt;
&lt;p&gt;In combination with presenting source code for Visual Studio the Add-in &lt;a href="http://copysourceashtml.codeplex.com/"&gt;CopySourceAsHtml&lt;/a&gt; is available.&lt;/p&gt;</description></item><item><title>Wie spricht man den Lambda-Operator aus?</title><link>http://blog.marko-apfel.de/posts/wie-spricht-man-den-lambda-operator-aus/</link><pubDate>Wed, 05 May 2010 09:27:00 +0200</pubDate><guid>http://blog.marko-apfel.de/posts/wie-spricht-man-den-lambda-operator-aus/</guid><description>&lt;p&gt;Da gibt es unterschiedliche Auffassungen.&lt;/p&gt;
&lt;p&gt;Im Englischen:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Func f = x =&amp;gt; x * 2;
&lt;ul&gt;
&lt;li&gt;”x goes to x * 2”&lt;/li&gt;
&lt;li&gt;”x maps to x * 2”&lt;/li&gt;
&lt;li&gt;”x becomes x * 2”&lt;/li&gt;
&lt;li&gt;”x induces x * 2”&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Func test = c =&amp;gt; c.City == &amp;ldquo;London&amp;rdquo;;
&lt;ul&gt;
&lt;li&gt;&amp;ldquo;c for which c.City equals London&amp;rdquo;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Im Deutschen:&lt;/p&gt;</description></item><item><title>Gefahren des “cleanup code refactoring” im Zusammenhang mit P/Invoke und übergebenen Strukturen</title><link>http://blog.marko-apfel.de/posts/gefahren-des-cleanup-code-refactoring-im-zusammenhang-mit-p-invoke-und-ubergebenen-strukturen/</link><pubDate>Wed, 28 Apr 2010 09:40:00 +0200</pubDate><guid>http://blog.marko-apfel.de/posts/gefahren-des-cleanup-code-refactoring-im-zusammenhang-mit-p-invoke-und-ubergebenen-strukturen/</guid><description>&lt;h2 id="problemkontext"&gt;Problemkontext&lt;/h2&gt;
&lt;p&gt;So schön auch das automatische “cleanup code refactoring” von ReSharper ist, im Zusammenhang mit Strukturdefinitionen, die als Übergabe-Parameter für unmanaged Code Aufrufe benötigt werden, lauert eine große Gefahr.&lt;/p&gt;
&lt;p&gt;Standardmäßig ist im Profil “Full Cleanup” die Option “Reorder type members” auf “Yes” gestellt.&lt;/p&gt;</description></item><item><title>Nachtrag: Casting Anti-Pattern</title><link>http://blog.marko-apfel.de/posts/nachtrag-casting-anti-pattern/</link><pubDate>Thu, 29 Oct 2009 12:40:00 +0100</pubDate><guid>http://blog.marko-apfel.de/posts/nachtrag-casting-anti-pattern/</guid><description>&lt;p&gt;Wie so oft im Leben sind manche Dinge auf den zweiten Blick komplexer als sie auf dem Ersten den Anschein haben.&lt;/p&gt;
&lt;p&gt;Es kam die Anfrage, ob es nicht doch einen Unterschied zwischen &amp;ldquo;as&amp;rdquo; und &amp;ldquo;is&amp;rdquo; gibt &amp;amp; dann wurden noch ein paar Inputs gefunden, dass im Falle des &amp;ldquo;Überladens von Cast-Operatoren&amp;rdquo; mögliche Fallen lauern.&lt;/p&gt;</description></item><item><title>Casting Anti-Pattern</title><link>http://blog.marko-apfel.de/posts/casting-anti-pattern/</link><pubDate>Thu, 29 Oct 2009 12:35:00 +0100</pubDate><guid>http://blog.marko-apfel.de/posts/casting-anti-pattern/</guid><description>&lt;p&gt;in unten stehendem Code ist ein Anti-Pattern, welches immer wieder im ArcObjects-Kontext zu beobachten ist.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-cs" data-lang="cs"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;element&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="n"&gt;IMapSurroundFrame&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;IMapSurround&lt;/span&gt; &lt;span class="n"&gt;mapSurround&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;IMapSurroundFrame&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="n"&gt;element&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;MapSurround&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="p"&gt;..&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Es wird eine is-Abfrage gemacht (element is IMapSurroundFrame) und dann ein Stück später der tatsächliche Cast ((IMapSurroundFrame)element).&lt;/p&gt;</description></item><item><title>Visual Studio 2005 and 2008 compatibility with ReSharper</title><link>http://blog.marko-apfel.de/posts/visual-studio-2005-and-2008-compatibility-with-resharper/</link><pubDate>Wed, 21 Oct 2009 08:57:00 +0200</pubDate><guid>http://blog.marko-apfel.de/posts/visual-studio-2005-and-2008-compatibility-with-resharper/</guid><description>&lt;p&gt;In our team we have developers with Visual Studio 2005 and 2008. Often we have projects which must be coded by a mixed team.&lt;/p&gt;
&lt;h2 id="visual-studio-2005-and-2008-compatibility-for-project-files"&gt;Visual Studio 2005 and 2008 compatibility for project-files&lt;/h2&gt;
&lt;p&gt;Normally this is no problem because adding projects in Visual Studio 2005 and manually introducing the ToolsVersion=&amp;ldquo;2.0&amp;rdquo; attribut in the new csproj-file allows an coexisting working when using two sln-files for Visual Studio 2005 and 2008.&lt;/p&gt;</description></item><item><title>Using images and cursors in resources</title><link>http://blog.marko-apfel.de/posts/using-images-and-cursors-in-resources/</link><pubDate>Sat, 01 Nov 2008 12:30:00 +0100</pubDate><guid>http://blog.marko-apfel.de/posts/using-images-and-cursors-in-resources/</guid><description>&lt;p&gt;Often i see code-constructs like&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-cs" data-lang="cs"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;try&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;bitmapResourceName&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;GetType&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="n"&gt;Name&lt;/span&gt; &lt;span class="p"&gt;+&lt;/span&gt; &lt;span class="s"&gt;&amp;#34;.bmp&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="m"&gt;4&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Bitmap&lt;/span&gt; &lt;span class="n"&gt;bitmap&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;Bitmap&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;GetType&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;bitmapResourceName&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="m"&gt;5&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="m"&gt;6&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Exception&lt;/span&gt; &lt;span class="n"&gt;ex&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="m"&gt;7&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="m"&gt;8&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;System&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Diagnostics&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Trace&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#34;Invalid bitmap.&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="m"&gt;9&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The corresponding codetree has the structure:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://web.archive.org/web/20161202000413id_/http://marko.apfel.googlepages.com/UsingImagesInResources.01.png" alt="Screenshot for Using images and cursors in resources" loading="lazy" decoding="async"&gt;&lt;/p&gt;
&lt;p&gt;This works as so long as the bitmap is near the calling component and the names are similar. If the name of Form2 is changed (maybe through refactoring) the developer must remember, that there is a corresponding bitmap. The problems are preassigned!&lt;/p&gt;</description></item></channel></rss>