Archive for the ‘C#’ Category
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 »
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 »
Posted by jpluimers on 2016/02/23
This indeed works very well:
All console output is shown in the build log.
So when you need more context on tests that succeed, you can just output them on the Console.
A practical use: testing the sending of SMS messages over HTTPS where the intermediate proxy can change and was giving different effects.
Logging the actual proxy used correlated some run-time findings. Based on that we could write better tests.
–jeroen
via: nunit – How can I view .NET trace logs in TeamCity? – Stack Overflow.
Posted in .NET, Agile, C#, Continuous Integration, Development, MSTest, Software Development, TeamCity, Testing.NET, Unit Testing, VSTest | Leave a Comment »
Posted by jpluimers on 2016/02/16
When you own the full stack:
virtual machine (Build 201602)
These installs contain:
- Windows 10 Enterprise Evaluation, Version 1511
- Visual Studio 2015 Community Update 1
- Windows developer SDK and tools (Build 10586)
- Windows IoT Core SDK and Raspberry Pi 2 (Build 10586.0.151029-1700)
- Windows IoT Core project templates (Version 1.0)
- Microsoft Azure SDK for .NET (Build 2.8.2)
- Windows Bridge for iOS (Build 0.1.0.160114)
- Windows UWP samples (Build 2.0.4)Windows Bridge for iOS samples
The VMware VM link redirects to https://windowsdeveloper.azureedge.net/vm-1602/Win10Eval_1602_VMware.zip
Also available for Hyper-V, VirtualBox, Parallels
–jeroen
Source: Get a Windows 10 development environment – Windows app development
Posted in .NET, .NET 4.5, C#, C# 5.0, C# 6 (Roslyn), Cloud Development, Development, Hardware Development, Raspberry Pi, Software Development, VB.NET, VB.NET 14.0, Visual Studio 2015, Visual Studio and tools, Windows Azure | Leave a Comment »
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 »
Posted by jpluimers on 2016/02/10
Thanks User Josh Close – Stack Overflow. for answering the below on Stack Overflow: it got my Resharper Alt-Enter key workign again.
Re-apply Visual Studio keyboard scheme:
- (VS2013 latest ReSharper)
- ReSharper > Options > Environment > Keyboard & Menus > ReSharper Platform keyboard scheme: Visual Studio > Apply Scheme > Save.
- This will reset the shortcut keys for ReSharper.
- (older versions)
- ReSharper > Options > Environment > General > Visual Studio Integration > Apply
–jeroen
via: visual studio – Resharper Alt Enter not working – Stack Overflow.
Posted in .NET, C#, Development, Keyboards and Keyboard Shortcuts, Power User, Software Development, Visual Studio 2013, Visual Studio and tools | Leave a Comment »
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 »
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 »
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 »
Posted by jpluimers on 2015/12/15
Quite a while ago I learned about the clip.exe tool.
clip.exe is a nifty tool that allows you to copy console text output to the clipboard. Though shipping with Windows Server 2003, it wasn’t part of Windows XP, but as of Windows Vista it shipped on desktop versions of Windows.
Digging a bit deeper, I found out it was already part of the Windows NT 4 Resource Kit.
So I wrote PasteText:
PasteText: the reverse of clip.exe; pastes Clipboard.GetText() or Clipboard.GetFileDropList() to the standard output.
The full source code is below and in my repository.
There are many examples on the internet about Clipboard.GetText, but there is very little about Clipboard.GetFileDropList. Read the rest of this entry »
Posted in .NET, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, C#, C# 3.0, C# 4.0, C# 5.0, Development, Software Development, The Old New Thing, Windows Development | Leave a Comment »