Sasha Sydoruk

Building a better mousetrap with XHTML, AJAX and RSS

Archive for the '.net' Category

Could not find file ‘Microsoft.Windows.CommonLanguageRuntime, Version=2.0.50727.0′

Today I was working with a solution that had 2 console applications. Console application A was creating a child application domain and executing the console application B in the child domain. Console application A had a project reference to console application B.

Everything worked until I decided to turn down code access security in the assembly that is being executed. Properties -> Security -> Enable ClickOnce Security Settings. Select “This is a partial trust application”. For ClickOnce Security Permissions pick “Internet” zone.

Now, when I try to rebuild the solutions I get this - Could not find file ‘Microsoft.Windows.CommonLanguageRuntime, Version=2.0.50727.0′.

To resolve this problem you have to uncheck “Enable ClickOnce Security Settings”. Once you do it, you will be able to rebuild your solution.

But what if you want to keep your ClickOnce security settings? Make sure you reference your assembly B as a file and not as the project.

3 comments

Variable number of digits after the decimal point

Recently I had to format a decimal number to have at least 2 numbers after the decimal point. No big deal. Just use this format for string.Format - “{0:.00}”. But the tricky part was to show more numbers after the decimal point if available. Here is some possible combinations:

Decimal

Desired Output

Hmm… Do I need to write custom logic to handle all these cases?

No!

Here is the format you can use to achieve the desired result - “{0:.00##}”. This way everything gets formatted properly, and, as added benefit, all decimals that have more than 4 digits after the decimal point get rounded properly.

Quick and elegant!

No comments

Entity Mapping in ADO.NET vNext

Straight from the horse’s mouth - Entity Mapping in ADO.NET vNext

No comments

Working with hidden variables in ASP.NET 1.1 and 2.0

While working on an ASP.NET page I had to read and write some hidden variables in my code behind.

I figured I could use the following:

Page.RegisterHiddenField(”test”, “testvalue”);

This would create a hidden variable in my HTML which I should be able to access with JavaScript like this:

document.getElementById(’test’).value

The task seemed easy, and I figured it would take around 10 minutes to get everything working. Only there was one problem. The hidden field was rendered like this:

<input type=”hidden” value=”testvalue” />

What is the problem here? Id and/or name are missing! And because of it, I cannot access this variable in my JavaScript.

What is the solution? Use HtmlInputHidden. Here is how to use it.

<input type=”hidden” id=”test” runat=”server” />

And in your code-behind you can assign correct values:

test.Value = “testvalue”

Make sure that the HtmlInputHidden is registered.

protected HtmlInputHidden test;

Now, I encountered this problem in ASP.NET 1.1; In ASP.NET 2.0 this problem has been resolved. Using Page.RegisterHiddenField will produce something similar to this:

<input id=”test” name=”test” type=”hidden” value=”testvalue” />

But, Page.RegisterHiddenField is marked as obsolete, so you can still use it, but it is not recommended. What is the recommended solution?

ClientScriptManager.RegisterHiddenField(string hiddenFieldName, string hiddenFieldInitialValue)

This is the recommended way to work with hidden variables in ASP.NET 2.0. To find out more information - http://msdn2.microsoft.com/en-us/library/system.web.ui.clientscriptmanager.registerhiddenfield.aspx

2 comments

Code Access Security - It is not easy…

While preparing for 70-536 I finally approached the topic of code access security and, just like I feared, it is not easy. No wonder it didn’t get the wide adoption that Microsoft hoped for. CAS does not fall into pit of success. It is much easier to do the wrong thing as opposed to being very easy to do the right thing.

While looking for more info on CAS I found this good post that clarified some of the things for me. Maybe it will help you as well.

No comments

SubSonic - The Zero Code DAL

I have blogged earlier about Streamlined. Streamlined is a great way to very quickly create admin portion of the site in Rails. Well, it seems like .net and asp.net people are trying to achieve similar results.

Meet SubSonic. It used be known as ASP.NET ActionPack, but recently it was renamed to SubSonic.

Subsonic helps you create DAL classes and UI in ASP.NET. It looks very promising and I can’t wait to try it out in my project.

SubSonic support SQL Server, MySql and Enterprise Library. It works only with ASP.NET 2.0    

No comments

List of tools for PowerShell

secretGeek is at it again. He has a great list of tools for PowerShell here. Thank you for a wonderfull post.

1 comment

List of TFS tools on CodePlex

Buck Hodges has a good list of TFS tools on CodePlex.

No comments

IIS 7.0 RC1

Another great post from Scott Guthrie about IIS 7.0.

I can’t wait for this thing to come out; but it will be a while. IIS 7.0 will be available with Vista Client for development, but the Vista Server will come out in a year. And that means you can play with it, but you cannot really deploy on it. It seems though that discountasp offers some hosting on IIS 7.0.

Anyways, the good news is that you can create more than one site in Vista Client and you can also have more than 10 connections.

No comments

Getting ready for 70-536

Currently I am getting ready to take Microsoft’s 70-536. Recently I found this great list of all the topics to the exam and links to msdn that explain them.

Edit:

Kevin asked me to link to a book that I am using to prepare for the exam; here it is - MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0 Application Development Foundation. I have almost finished reading the book for the first time. I am going to reread it again and throughly work through the examples.

Here is my opinion about the book. It is pretty good. It covers a lot of topics and has more than 1000 pages. Because of the sheer breadth of the covered material some topics are not described in the detail they deserve. Despite of that, it is a great study guide. My rating – 85%.

Now, the testing software that comes with this book is unbelievingly lame. I cannot stress enough how lame and unusable that stupid software is. It is designed for screens with resolution 800 * 600. It looks like it was written in VB6, thus it does not scale well on high resolution monitors. I just cannot believe that this software was actually released. What a shame… I hope that other books in the series will have better software.

5 comments

« Previous PageNext Page »