2012-08-09

IIS6 and .cshtml files

By default IIS 6 does not want to execute these kind of files which gave me problems when installing blogengine. What I did to resolve this was: 1. open IIS 2. right click on my web site and choose properties 3. click on Home directory tab 4. click on Configuration button 5. click on "Insert.." button 6. write cshtml as extension and c:\windows\microsoft.net\framework\v4.0.30319\aspnet_isapi.dll as path

2010-11-19

CyberPower Intelligent LCD CP1350AVRLCD with not so intelligent software PowerPanel

I purchased the ups CP1350AVRLCD because of the small format, lcd screen and great uptime. My main purpose was watch 2 servers, 1 NAS, one switch and one router. No problem – those could just be plugged in.

Before purchasing I did not look at software. I just *expected* that it has some basic functionality to notify me on email and shut servers down when battery level become lower.

I was wrong. The “Personal Edition” that came with the UPS was only able to beep and shut down one computer. That did not help me. I searched for another application and found the “Business Edition”. I was ready to pay for it but no – after talking to support they told me that that software did not support my UPS. They also told me that I should buy another UPS that supported this software. This did, of course, not help me at all as I had already purchased the product.

Anyway, I was able to start that “Business edition” but I was not impressed with that either.

So, I started to try to communicate with the UPS and finally found a way to get battery level and power status from the UPS. I will now add some email support to that test application and also support to shut down multiple computers.

If you are reading this and would like to have this alternative application then please let me know!

2010-03-20

The service did not respond to the start or control request in a timely fashion.

So, I released a new version of one of my applications. This application is a Windows service. Nothing strange about this version so I rolled it out. Suddenly, a lot of users where complaining about that the service did not start.

One strange thing was that when changing the user that runs the service from SYSTEM (which is my default) to a local administrator it worked.

I tried to create similar environments but could not reproduce the problems. I got desktop access on one of the users server and saw, while running ProcessExplorer that a lot of queries were done to CryptoAPI dll’s before it finally gave up and timed out. This led me to think of that it was some deeper security problem.

I recently started signing my service with GlobalSign instead of Thawte so maybe it was something about that. I ran into this KB: http://support.microsoft.com/kb/936707

So, I added the following lines to the config and it started to work when running as SYSTEM:

<configuration>
    <runtime>
        <generatePublisherEvidence enabled="false"/>
    </runtime>
</configuration>

I don’t know if the problem is specific to GlobalSign. Implementation error or that root certificates are missing. Or that my previous signing certificate was cached in some way. If you know – then please let me know. Right now, I am just satisified that this solution works.

2010-03-10

ClickOnce and obfuscation with .NET Reactor

 

The above could have been easy and straightforward if there weren’t for, what I call, design errors in the building and publish process.

My first thought was that I could just add a post-build event, calling a command line protecting the applications/dll’s then just copy them back to the output folder. I was thinking that the “Publish” feature would use this output folder.

That weren’t the case unfortunately.

The Publish feature seems to store the built exe’s in memory or in a temporary location. Then it will overwrite anything in the output folder. So, your recently protected items will be overwritten. Then, after this, all signing and publishing magic will occur.

As my original approach did not work I had to do this manually:

1. I need to publish first (which builds).
2. Then protect the files
3. Copy the protected files over the build version folder
4. Update the application.manifest file (so that new hashes are createad for each file)
5. Re-sign the manifest file
6. Update the ApplicationName.Application file so it hashes the new manifest file
7. Re-sign the *.Application file

To work with the files we use the manifest tool mage.exe. I am not sure if the version for Visual Studio 2008 has all functionality so I downloaded the RC for VS2010. I run all commands to the VS2010 command prompt.

We don’t want to create new manifest files as that would reset other stuff you may enter within the Publish designer (and may not exist as option in mage.exe).

Here is a rough script how I did it:

REM http://msdn.microsoft.com/en-us/library/ms165431.aspx
REM http://msdn.microsoft.com/en-us/library/acz3y3te%28VS.100%29.aspx
REM msbuild /target:publish /property:BootstrapperEnabled=true

REM Protect files
"C:\Program Files (x86)\Eziriz\.NET Reactor\dotNET_Reactor.exe" -project c:\sourcefiles\Reactor\AnyConnect.nrproj

REM Copy protected files
copy C:\sourcefiles\code\AnyConnect\bin\Release\protected\*.dll "C:\sourcefiles\code\AnyConnect\bin\Release\app.publish\Application Files\AnyConnect_1_2_0_0\"
copy C:\sourcefiles\code\AnyConnect\bin\Release\protected\*.exe "C:\sourcefiles\code\AnyConnect\bin\Release\app.publish\Application Files\AnyConnect_1_2_0_0\"

REM update hash files and sign
cd "C:\sourcefiles\code\AnyConnect\bin\Release\app.publish\Application Files\AnyConnect_1_2_0_0\"
mage -Update AnyConnect.exe.manifest
mage -Sign AnyConnect.exe.manifest -CertFile c:\sourcefiles\sign\netcart.pfx -Password myPassword

REM update application file
cd "C:\sourcefiles\code\AnyConnect\bin\Release\app.publish\
mage -Update AnyConnect.application -AppManifest "Application Files\AnyConnect_1_2_0_0\AnyConnect.exe.manifest"
mage -Sign AnyConnect.application -CertFile c:\sourcefiles\sign\netcart.pfx -Password myPassword

You can improve this a lot so you don’t have to update version number and maybe even build the project but right now this works for me.

Remember when uploading the project to upload both the version folder and the *.application file.

2010-02-03

System.Data.SqlClient.SqlException: Incorrect syntax near 'storedProcedureName'.

So, you were trying to use the SqlCommand and got this cryptic error when you tried to execute a stored procedure?

Try changing the CommandType property on the SqlCommand:

command.CommandType = System.Data.CommandType.StoredProcedure

The CommandType is by default Text.

2009-10-20

TF14040: The folder {0} may not be checked out.

 

After moving to a new computer and started to open my old Visual Studio projects I got this error when trying to open an old dataset for example.

tf14040

The problem is related to permissions and I got around this by removing the Read-only flag on the project folder.

2009-09-19

Edit hosts file in Vista/Windows 7

 

What is the hosts file?

The hosts file contains a list of IP address to hostname mappings and can be useful especially for web developers if they need to point a hostname to a specific IP address while developing or testing a website, without having to change settings on a DNS server. On Linux and Unix systems it is typically at /etc/hosts and on Windows systems (Windows 2000, XP, Vista, Windows 7) at c:\windows\system32\drivers\etc\hosts

Errors when editing the file

Depending on operative system you may get derrors below when trying to edit and save the hosts file:

“Contact administrator”, “Permission denied”, “Path is not correct”.

Run as administrator

What you need to do this to open Notepad as administrator. Right click on Notepad and choose Run as Administrator. Then browse to the hosts file (you may need to turn on “View all files” as the hosts file does not have the txt extension”. Now, just edit and save the file.