The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,860 other subscribers

Archive for the ‘C# 4.0’ Category

Writing tests for http / https request: Postman, SoapUI, Advanced REST client.

Posted by jpluimers on 2016/06/21

I’m using these Chrome Extensions for most of the http / https call mockups, and after that put them in SoapUI (which despite the name also does REST and has come a long way sinceSource: SoupUI – as sometimes that is the only thing that works):

You can get both Postman versions through GetPostman.com as well.

–jeroen

Posted in .NET, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, ASP.NET, C#, C# 3.0, C# 4.0, C# 5.0, Chrome, Communications Development, Development, Google, HTTP, Internet protocol suite, Power User, REST, Software Development, TCP | 1 Comment »

Did you know… How to change the build order for your solution? – #333 – Sara Ford’s Weblog – Site Home – MSDN Blogs

Posted by jpluimers on 2016/06/08

Boy I wish I had known this earlier. Like years ago…

In the Solution Explorer:

  1. Right Click Project
  2. Project Build Oder.
  3. Use the dialog to change the build order

It is next to the “Project Dependencies” in this image from Sara Ford:

Sara Ford: change

Sara Ford: change “Project Build Order”

In the resulting dialog, you can change the build order within your solution.

This can be very useful when – for various reasons – you cannot have Project Level dependencies for an assembly, but have to have Assembly Reference dependencies for individual assemblies.

At a client I bumped into this, and this dialog was a life saver for us.

Others have used it because some Visual Studio versions miscalculate the dependencies.

–jeroen

Did you know… How to change the build order for your solution? – #333 – Sara Ford’s Weblog – Site Home – MSDN Blogs.

Posted in .NET, C#, C# 2.0, C# 3.0, C# 4.0, C# 5.0, C# 6 (Roslyn), Development, Software Development, Visual Studio 11, Visual Studio 2008, Visual Studio 2010, Visual Studio 2012, Visual Studio 2013, Visual Studio and tools | Leave a Comment »

NHibernate, LINQ, Oracle and the placement of Take: avoid “Specified method is not supported.”

Posted by jpluimers on 2016/03/22

Even though as of 12c R1, Oracle supports a row limiting clause, NHibernate 4.2 with Oracle.DataAccess.dll 2.112.3.0 does not support that.

When you let it generate the SQL for a LINQ Take call to limit the number of results, you get an exception like this (full exception and stack trace are below):

System.NotSupportedException was unhandled by user code
  HResult=-2146233067
  Message=Specified method is not supported.

The place where you Take is important, as this does fail:
Read the rest of this entry »

Posted in .NET, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, .NET ORM, C#, C# 2.0, C# 3.0, C# 4.0, C# 5.0, C# 6 (Roslyn), Database Development, Development, NHibernate, OracleDB, Software Development | Leave a Comment »

Reminder to self: app.config and “ORA-12154: TNS:could not resolve the connect identifier specified”

Posted by jpluimers on 2016/03/17

When you have one app.config for your whole set of DTAP environments (develop/test/acceptance production), every once in a while you get this error:

ORA-12154: TNS:could not resolve the connect identifier specified

For this particular setup, it means the replacement of parameters in the app.config with actual values from the DTAP went wrong (or was missing). For that we’ve some steps in both the PreBuildEvent and PostBuildEvent of the .csproj file:

PreBuildEvent:

del "$(ProjectDir)$(TargetFileName).config"
copy "$(ProjectDir)app.config" "$(ProjectDir)$(TargetFileName).config"

PostBuildEvent:

powershell -noprofile -file Replace-Parameter.ps1 -Path "$(TargetDir)$(TargetFileName).config"

The PreBuildEvent looks like it is not needed, but sometimes Visual Studio forgets to perform the copy action.

–jeroen

Posted in .NET, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, .NET ORM, C#, C# 2.0, C# 3.0, C# 4.0, C# 5.0, C# 6 (Roslyn), Database Development, Development, NHibernate, OracleDB, Software Development | Leave a Comment »

assembly:InternalsVisibleTo: .net – C# “internal” access modifier when doing unit testing – Stack Overflow

Posted by jpluimers on 2016/03/16

It seems I always forget about the InternalsVisibleTo attribute which allows you to specify which external assembly can see your internal types and type members:

Internal classes need to be tested and there is an assembly attribute:

using System.Runtime.CompilerServices;
[assembly:InternalsVisibleTo("MyTests")]

Add this to the project info file, e.g. Properties\AssemblyInfo.cs.

Thanks Eric Schaefer for that answer.

–jeroen

via .net – C# “internal” access modifier when doing unit testing – Stack Overflow.

Posted in .NET, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, C#, C# 2.0, C# 3.0, C# 4.0, C# 5.0, C# 6 (Roslyn), Development, Software Development | Leave a Comment »

Sometimes it is Visual Studio’s fault: failure to copy file in a post build event

Posted by jpluimers on 2016/02/25

Not sure yet why, but every now and then I get a failure like this in Visual Studio (at least in 2013 and up):

2>C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(4548,5): error MSB3073: The command "copy /Y "C:\SomePath\SomeProjectName\bin\Debug\SomeProjectName.dll" "C:\SomePath\Shared Assemblies\"" exited with code 1.
2>Done executing task "Exec" -- FAILED.

Most of the times it is me at fault: some process still is using it.

But sometimes, it is devenv.exe (Visual Studio itself) that keeps it locked, even though nothing is running (in fact it can happen right after you loaded the project in Visual Studio 2013).

I found this out by using “Process Explorer Search” (Ctrl+F or Find Handle or DLL).

Not sure why yet.

–jeroen

Posted in .NET, C#, C# 4.0, Development, Software Development, Visual Studio 2013, Visual Studio and tools | Leave a Comment »

NTLM and Kerberos Authentication for a WebRequest and a WebProxy

Posted by jpluimers on 2016/02/16

This was very useful to get a WebClient with a WebProxy configured to use a proxy server that is based on NTLM authentication.

The note in the MSDN NTLM and Kerberos Authentication. documentation however was totally wrong.

String MyURI = "http://www.contoso.com/";
WebRequest WReq = WebRequest.Create MyURI;
WReq.Credentials = CredentialCache.DefaultCredentials;

Note NTLM authentication does not work through a proxy server.

This code works perfectly fine as the CredentialsCache.DefaultCredentials contains your NTLM or Kerberos credentials.
It even works when you have a local Fiddler http proxy as a facade in front of your NTLM proxy.

Read the rest of this entry »

Posted in .NET, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, C#, C# 2.0, C# 3.0, C# 4.0, C# 5.0, C# 6 (Roslyn), Development, Fiddler, Software Development, Web Development | Leave a Comment »

winforms – Where is the Tab Order Assignment dialog in Visual Studio 2012+? – via: Stack Overflow

Posted by jpluimers on 2016/01/27

Duh: same for VS2013

It is still available, you just need to add it back to the View menu. Tools + Customize, Commands tab, Menu bar = View. Select the menu item in Controls where you want to insert it, say the bottom one. Then Add Command, Category = View, Commands = Tab Order.

Source: winforms – Where is the Tab Order Assignment dialog in Visual Studio 2012? – Stack Overflow

–jeroen

Posted in .NET, .NET 4.0, .NET 4.5, C#, C# 3.0, C# 4.0, C# 5.0, Development, Software Development, Visual Studio 2012, Visual Studio 2013, Visual Studio 2014, Visual Studio 2015, Visual Studio and tools | Leave a Comment »

c# – How can I create a temp file with a specific extension with .net? – Stack Overflow

Posted by jpluimers on 2016/01/27

You’d think this is a simple question.

Be amazed by the many ways leading into to creating a temporary file with a specific extension.

This list doesn’t even cover all of them:

  • Create a file name based on GetTempPath, a Guid and an extension.
  • Use the TempFileCollection from the Compiler in System.CodeDom.
  • Get a random file name, then change the extension. Loop until it is unique.
  • Use a timestamp to generate unique file names.

All via: c# – How can I create a temp file with a specific extension with .net? – Stack Overflow.

Which one would you choose?

–jeroen

Posted in .NET, .NET 1.x, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, C#, C# 1.0, C# 2.0, C# 3.0, C# 4.0, C# 5.0, C# 6 (Roslyn), Development, RemObjects C#, Software Development | Leave a Comment »

Threading in C# – Free E-book

Posted by jpluimers on 2016/01/18

Still a great book. I love the chapter Threading in C# – Free E-book which you also can get as a PDF download.

It’s a chapter from C# 56/5/… in a Nutshell by Joseph Albahari. Great book!

Don’t forget to read these as well: Jon Skeet: Multi-threading in .NET: Introduction and suggestions (printable) Multi-threading in .NET: Introduction and suggestions (browseable)

--jeroen

Posted in .NET, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, C#, C# 2.0, C# 3.0, C# 4.0, C# 5.0, C# 6 (Roslyn), Development, Jon Skeet, Software Development, Visual Studio 2008, Visual Studio 2010, Visual Studio 2012, Visual Studio 2013, Visual Studio 2014, Visual Studio 2015, Visual Studio and tools | Leave a Comment »