.NET NUnit test – Assembly.GetEntryAssembly() is null

Implement the SetEntryAssembly(Assembly assembly) method given in http://frostwave.googlecode.com/svn-history/r75/trunk/F2DUnitTests/Code/AssemblyUtilities.cs to your unit test project. /// <summary> /// Use as first line in ad hoc tests (needed by XNA specifically) /// </summary> public static void SetEntryAssembly() { SetEntryAssembly(Assembly.GetCallingAssembly()); } /// <summary> /// Allows setting the Entry Assembly when needed. /// Use AssemblyUtilities.SetEntryAssembly() as first line in XNA … Read more

.NET Core dependency injection -> Get all implementations of an interface

It’s just a matter of registering all IRule implementations one by one; the Microsoft.Extensions.DependencyInjection (MS.DI) library can resolve it as an IEnumerable<T>. For instance: services.AddTransient<IRule, Rule1>(); services.AddTransient<IRule, Rule2>(); services.AddTransient<IRule, Rule3>(); services.AddTransient<IRule, Rule4>(); Consumer: public sealed class Consumer { private readonly IEnumerable<IRule> rules; public Consumer(IEnumerable<IRule> rules) { this.rules = rules; } } NOTE: The only collection … Read more

Beginning VSTO Development

Yeah, it can get confusing, especially given the skip-level naming conventions, etc. Essentially, you’ll need: Full version (not Express) of Visual Studio and the .NET version you’re targetting. One of the VSTO run times (VSTO 2003, VSTO 2005, VSTO 2005 SE, VSTO 2008, VSTO 2010). For what your asking, VSTO 2005 SE is probably your … Read more

WCF error: The caller was not authenticated by the service

If you use basicHttpBinding, configure the endpoint security to “None” and transport clientCredintialType to “None.” <bindings> <basicHttpBinding> <binding name=”MyBasicHttpBinding”> <security mode=”None”> <transport clientCredentialType=”None” /> </security> </binding> </basicHttpBinding> </bindings> <services> <service behaviorConfiguration=”MyServiceBehavior” name=”MyService”> <endpoint binding=”basicHttpBinding” bindingConfiguration=”MyBasicHttpBinding” name=”basicEndPoint” contract=”IMyService” /> </service> Also, make sure the directory Authentication Methods in IIS to Enable Anonymous access

Equivalent of Class Loaders in .NET

The answer is yes, but the solution is a little tricky. The System.Reflection.Emit namespace defines types that allows assemblies to be generated dynamically. They also allow the generated assemblies to be defined incrementally. In other words it is possible to add types to the dynamic assembly, execute the generated code, and then latter add more … Read more

What to do with “The version of SOS does not match the version of CLR you are debugging” in WinDbg?

This is what worked for me: Download the following DLLs: clr.dll mscordacwks.dll SOS.dll from this folder on the machine that generated the dump: C:\Windows\Microsoft.NET\Framework64\v4.0.30319 Run the following command. The path to SOS.DLL should be without quotes, unescaped path delimiters: .load path to downloaded SOS.DLL I think a new WinDbg session is required for this to … Read more

Does the .Net Framework 4.0 Installer include the .Net Framework 3.5?

The .NET 4.0 installer doesn’t include the .NET framework 3.5. There is some information on this topic in MSDN: The .NET Framework 4 is highly compatible with applications that are built with earlier .NET Framework versions, except for some changes that were made to improve security, standards compliance, correctness, reliability, and performance. The .NET Framework … Read more