Windows 10 – DotNet Development NO Visual Studio

October 16, 2018

Recently I needed to develop an VPN Builder for Windows 7 for the L2TP protocol.

To automate the VPN entries on the client and to hide the Private Shared Key for the user.

 

PowerShell can do this…  But does not support the cmdlet Add-VpnConnection onWindows 7

It is only available for Windows 10 Sad smile

 

SOLUTION :

1. Download the DotRas Library from the Nuget site

https://www.nuget.org/packages/DotRas.for.Win7/

image

Tip : Winking smile

When you have saved the .nupkg package you can just open this using 7-Zip

image

Extract the nice documentation file DotRas.chm that is included.

image

And extract the DotRas.dll (for your appropriate .Net version 2.0 or 4.0)

In my case I used the DotNet 2.0 version

 

2. VB.Net Source code

On the net you can find relevant source code to build your application for L2TP, if you want to have a head start.

https://blog.cjwdev.co.uk/2011/05/19/automate-creation-of-an-l2tp-vpn-with-pre-shared-key-and-automatically-use-windows-credentials/

And modify to your own needs ….

 

3. Compile your application

You can use the commandline compiler VBC.exe that is part of your local DotNet installation on any Windows machine.

Or you can use my Visual Studio Light wrapper  Smile

 

%systemroot%\Microsoft.NET\Framework\v2.0.50727\vbc.exe /nowarn /nologo /quiet /debug- /t:Winexe VPN_L2TP_Builder.vb /r:DotRas.dll -out:VPN_L2TP_Builder.exe -win32resource:VPN.res

 

As you can see I needed to reference the DotRas.dll Assembly and I used the custom Resources to assing a custom ICON and File Properties.

See here on how to build a custom Resource file using Resource Hacker

 

4. Result

image

 

As you can see we don’t need 10 ton of software, just to build a simple functional DotNet Application Smile

 

Some extra tips for L2TP errors here  Winking smile

 

 

Enjoy!

Advertisements

Resource Hacker – Update File Icon & Resource Data

October 15, 2018

As you might know by know I am not a big fan of installing 10 ton of software to get my simple things done.

One of them is adding file versioning or file Icons to my custom build .Net applications.

For which I use my also my custom build vbc.net or csc.net wrapper for Visual Studio

If you need to add you custom ICON and or VERSIONING

You can use some vbc.net compiler options, see here for the full list vbc compiler or  csc compiler options.

SOLUTION :

Download Resource hacker

I still use an old Version 3.4, which still runs fine.

image

1. Open your compile .exe file

image

2. Add or Replace Icons

Right click the 0 in the ICON section and Select Replace

image

3. Add or Replace File Properties

Select 0 in the Version Info section

image

Modify the File Property Values according to you needs. And click on the COMPILE button.

Next save this as a RESOURCE file.

image

For Example : My.res

Once this is done you can pick the settings up when compiling your VB or C# application, using this compiler option :

-win32resource

Example : –win32resource:My.res

See here in a real life example

 

Enjoy !


Windows Server 2016 – Perflib Error Event ID 1008

August 20, 2018

Some servers make notice of regular Perflib Event ID 1008 Error

image

image

SOLUTION :

Run these commands

C:\Windows\system32\lodctr.exe /R

C:\Windows\SysWOW64\lodctr.exe /R

C:\Windows\System32\wbem\winmgmt.exe /RESYNCPERF

C:\Windows\SysWOW64\wbem\winmgmt.exe /RESYNCPERF


image

After these commands you might see the Warning Event ID 2003

image

image

Run this command :

lodctr /T:TermService

And reboot the server to make sure all errors are gone

More info see here :

https://www.admin-enclave.com/en/articles/windows/306-resolved-the-open-procedure-for-service-bits-in-dll-c-windows-system32-bitsperf-dll-failed-performance-data-for-this-service-will-not-be-available-the-first-four-bytes-dword-of-the-data-section-contains-the-error-code.html

Success !


Windows 10 – Running ASP.NET Core 2.0 on Mono

August 5, 2018

After installing Mono on Ubuntu using Windows 10 WSL, see here

You can start cross compiling you ASP .NET Core 2.0 Apps to run on Mono

1. Publush for Linux

Use this command : dotnet publish -r linux-x64 -c Release

image

2. Install DotNet Core on Ubuntu :

First in widows go to the project folder where you find the published project see step 1.

image

And start the WSL there. Open command prompt in that folder and run BASH

image

Run these commands to install .Net Core Framework on Mono :

curl https://packages.microsoft.com/keys/microsoft.asc | gpg –dearmor > microsoft.gpg

sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg

sudo sh -c ‘echo “deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-xenial-prod xenial main” > /etc/apt/sources.list.d/dotnetdev.list’

sudo apt-get update

sudo apt-get install dotnet-sdk-2.1.3

3. Install and Configure Web Server Nginx

sudo apt-get install nginx

It runs on PORT 80 by default, so stop other windows webservers if needed.

image

next run this command :

sudo service nginx start

And test it by opening a browser in windows, you should see this webpage.

clip_image002

To stop the webserver run :

sudo service nginx stop

4. Configure nginx as reverse proxy server

Go in Windows to the Linux installation folder …

Open the file in Notepad++ and make the make the following changes in the DEFAULT file:

clip_image002[6]

C:\Users\xxxx\AppData\Local\lxss\rootfs\etc\nginx\sites-available

Change the default port from 80 to whatever you like, example 81

Comment out this line : #try_files $uri $uri/ =404;

Add this line proxy_pass line : proxy_pass http://localhost:5000;

image

You can also use the VI editor in Linux if you like this :

sudo vi /etc/nginx/sites-available/default

Now test the config changes are working :

sudo nginx -t

If you did not stop the server you can do a reload :

sudo nginx -s reload

6. Test the .Net Core App in WSL using Bash

Open Bash in the Published folder

clip_image002[8]

And TEST the Linux .Net Core application like this :

dotnet FirstMvc.dll

image

I get an error because the Linux is CASE Sensitive. So try again using the correct command.

And the SQL Database location is not found.

Because I started it not from the default folder location, which should be C:\CoreIoT\ASPnetRazorSQLiteWsAPI\Data

image

But all runs well, so the .NET Core App is a try cross platfrom framework Smile

Enjoy!


Windows 10 – High Harddisk activity on wiatrace.log

March 11, 2018

You  may notice a high HD activity writing to the wiatrace.log file.

WIA stands for Windows Image Acquisition Library.

This is used if you have a Printer scanner installed. Even if you don’t use the Scanner the log file writes debug info to it.

SOLUTION :

Open the registry and go to :

HKLM\System\CurrentControlSet\Control\StillImage\Trace\wiaservc.dll

image

Change the value to of TRACEFLAGS from 407 to 0

Check the disk activity again, it should be gone now Smile

Alternatively you can stop the Windows Image Acquisition (WIA) Service

image

Enjoy !


Xperia Z3 Compact GPS Not Working

May 2, 2017

We encountered a Sony Mobile where the GPS was not working suddenly ?

So I was thinking that a recent software update was the root cause…

Next I went on the Forum to see if there are where more issues like that… and indeed quite a lot found Confused smile

Solution :

Go into service mode by just dialing : *#*#7378423#*#* and then into Service Tests, GPS, Purge

See steps described on the Forum GPS not working,

image

But still it did not work ! Sad smile

This simple setting fixed it !

Go to Location Settings :

Go to MODE and change to HIGH ACCURARY

image

image

Problem Fixed… Smile


Windows Core IoT – Accessing a DotNet DLL assembly on a Raspberry PI3 using Windows Core IoT

January 23, 2017

In this post I showed how to create an Console app using my Visual Studio Light for ARM, to run on a Raspberry PI3 on Windows Core IoT.

Taking it one step further is that you access an DotNet Assembly that was created before, and seem to run as well on X86 as on ARM Smile

So most Assembly DLL’s seem to be architecture independend …

 

image

 

Let’s see here :

Using ILSpy you can see the source of the self made .NET Assembly.

image

 

image

I copied the DLL Assembly to the RPI3, did a remote access from PS IDE and ran the following code.

image

 

As you can see it ran without any issues ! the result was returned as expected … Smile

Enjoy !