Skip to main content

Posts

.NET Standard: Using the InternalsVisibleToAttribute

In .NET Standard projects, there is an AssemblyInfo class built-in , so you no longer need a separate AssemblyInfo.cs file in your project Properties. But what if you want to use the InternalsVisibleToAttribute ? This was one of the attributes I used a lot to expose the internals of my Assembly to my test projects. Turns out that it doesn’t matter really where you put this attribute. It is applied at the assembly level, so you can include in any source code file you like. Using the AssemblyInfo file was just a convenience. So what I did, was creating an empty .cs file and add the following code:

.NET Standard: Duplicate 'System.Reflection.AssemblyCompanyAttribute' attribute

In a ‘classic’ .NET project, you have an AssemblyInfo.cs file. This file contains all kind of information about your assembly After upgrading a classic .NET project to .NET Standard, I started to get errors about some of the properties inside the AssemblyInfo.cs file: A .NET Standard project already has the AssemblyInfo information built-in. So after upgrading you end up with 2 AssemblyInfo specifications, leading to the errors above. The solution is to remove the original AssemblyInfo.cs file in the Properties folder. Remark: If you want to change the assembly information, you now have to use the Package tab inside your Project Properties .

RabbitMQ–Configure access to Management portal

As mentioned in a previous post , it is probably a good idea to enable the RabbitMQ Management plugin to help you track what’s going inside your service broker. Now if you try to access the Management plugin using the default guest account(which you should probably remove), outside the server itself, you get a ‘Login failed’ error. Let’s fix this: Logon to the server Browse to the management portal using the localhost address: http://localhost:15762 Logon using the guest account Click on the Admin tab and scroll to the Add a user section Enter a Username and Password Specify one or more Tags as a comma separated list. If you want to give full access, enter ‘administrator’. Click on the Add user button Now click on the newly created user in the user list The set permission section is shown Leave the default settings and click Set permission . That’s it! Remark: You can do the same steps using the com...

RabbitMQ–Enable Management plugin

To simplify management and monitoring of your RabbitMQ Service Broker it is a good idea to install the management plugin(don’t expect anything fancy). To install it, logon to the server where you installed RabbitMQ Open a RabbitMQ command prompt Enter the following command rabbitmq-plugins enable rabbitmq_management You’ll get the following log output D:\Program Files\RabbitMQ Server\rabbitmq_server-3.6.12\sbin>rabbitmq-plugins en able rabbitmq_management The following plugins have been enabled:   amqp_client   cowlib   cowboy   rabbitmq_web_dispatch   rabbitmq_management_agent   rabbitmq_management Applying plugin configuration to rabbit@SERVER01 ... started 6 plugins. Now you can access the management portal using http://localhost:15672 If you want to access the portal from outside the server, you have to configure a firewall rule that allows TCP traffic on port 15...

ASP.NET Core–Configuring a WCF service

In an ASP.NET Core application(using the full .NET framework) we had to consume a WCF service. Should be easy right? Unfortunately it turned out that be more work than I expected. In a first post I explained the steps how to generate a Client Proxy, this post is about  setting the configuration. WCF configuration can be a daunting beast with a lot of options and things that can go wrong. The code generated by the proxy hardcodes (some part) of the configuration in the WCF proxy and provides you a partial method to override it but that’s not the approach we want to take. I know we’ll host the WCF service in IIS, so adding a web.config and putting the configuration logic over there sounds nice… Let’s try that: Open the generated proxy reference file  and remove the call to Service1Client.GetDefaultBinding() and Service1Client.GetDefaultEndpointAddress() in the constructor. ( Note: this is only for testing purposes) Right click on your ASP.NET Core proje...

ASP.NET Core–Connecting to a WCF service

In an ASP.NET Core application(using the full .NET framework) we had to consume a WCF service. Should be easy right? Unfortunately it turned out that be more work than I expected. I right clicked on my project and searched for an Add service reference… option. No luck, instead I saw a Connected Services section. Maybe that will do it? I right clicked on the Connected Services section and choose Add Connected Service . This opened up the Connected Services window but no option was available to connect to an existing WCF service Maybe the Find more services… link at the button will help me? This brought me to the Visual Studio Marketplace. And yes… a search for ‘WCF’ showed up a Visual Studio Connected Services plugin that allows to add a WCF Web service reference to .NET Core projects. Exactly what I needed. I clicked on Download, closed Visual Studio after which the installer appeared and I could install the extension. After the installat...

NHibernate–StaleObjectStateException

I’m currently working at a client where are (finally) migration from DB2 to SQL Server. One of the things we encountered is that DB2 is using a different precision(6 digits) for their DateTime than SQL Server, so as part of the migration process we change all target dates on SQL Server to DateTime2 to not loose any data. After migrating everything seemed to work until we tried to save an object through NHibernate to the database; we always got a StaleObjectStateException. Problem was that we were using one of these DateTime columns for concurrency checks. As NHibernate by default expects a DateTime instead of a DateTime2 we lost some precision when hydrating the objects from the database. When we later on tries to persist our changes, the concurrency check will see that the DateTimes are different resulting in a StaleObjectStateException. The solution was to change our mapping code to use DateTime2 instead. Here is our (updated) Fluent NHibernate code: And here is a similar ...