Wednesday, December 19, 2012
NHibernate Get vs Load behavior in whether returning the proxy or not
If it’s not there, then Get and Load will return the entity in a different way.
When calling Get, NHibernate will perform a roundtrip to database and return the non-proxy entity object or null in case the record does not exist:
var user = session.Get<User>(122);
For Load, NHibernate will return a proxy of the entity object or throw an exception if the record does not exist:
var user = session.Load<User>(122);
Suppose we have the following calls:
var a = session.Load<Assignment>(1);
var b = session.Get<Assignment>(1);
Note that in the 2nd case, b is a proxy and not the entity because the entity proxy exists in the session cache due to the Load call.
var a = session.Get<Assignment>(1);
var b = session.Load<Assignment>(1);
In this case b is a non-proxy entity object, due to the Get call.
Friday, November 16, 2012
Remote debugging in Visual Studio, target on a different domain
My computer is a Windows 7 32bits and I had to debug a ASP.NET 32 bit worker process running on a Windows Server 2008 64 bit machine.
The server is in a VPN and in a domain.
What I did was, on the server, I first ran this tool:
Start\Programs\Microsoft Visual Studio 2010\Visual Studio 2010 Remote Debugger (x86)
Make sure your user has permissions to debug the apps, so you can go to Tools\Options and click on Permissions. Your user should have Debug permission.
The tool says “Msvmon started a new server named ‘JohnDoe@VMXXXXXX. Waiting for connections’.
Now, in Visual Studio 2010 on my machine, I went to “Debug\Attach to Process” and in Qualifier, I put JohnDoe@XX.XX.XX.XX where XX.XX.XX.XX is the IP of the server. Note that I didn’t use the ‘JohnDoe@VMXXXXXX’. It didn’t work for me.
Two things worth mentioning:
1. you need to have the same user and password on the local machine. I created a separate account on my machine for this.
2. you cannot debug 64 bit processes from a 32 bit machine. Luckily, my processes were running as 32 bit processes so I could debug them.
HibernateException: Creating a proxy instance failed –> Unable to obtain public key for StrongNameKeyPair issue
I stumbled upon the following exception for a webapp of a particular site:
HibernateException: Creating a proxy instance failed –> Unable to obtain public key for StrongNameKeyPair.
Strange thing because this was only for one site, the other sites which have the same code didn’t have this issue.
This link gave me a good start:
http://stackoverflow.com/questions/5659740/unable-to-obtain-public-key-for-strongnamekeypair
“NHibernate is dynamically creating .NET assemblies (dynaic proxies) and needs to sign them. By default the Windows OS configures the crypto key storage to be machine level and stores the keys in C:\Documents and Settings\All Users\Application Data\Microsoft\Crypto\RSA\MachineKeys. Most likely your user can create (for example) a text file in this folder, but not delete it because you do not have full control.”
After reading this, what I did was I went to IIS Manager and checked the identity for the app pool which was running the webapp.
It was set to ApplicationPoolIdentity which creates a virtual account with the name of the new application pool and run the Application Pool's worker processes under this account:
http://forums.iis.net/t/1173831.aspx
Setting the identity to NetworkService made the app work fine like in other sites.
Sunday, October 30, 2011
Merged Dictionaries with ResourceDictionary set to linked XAML
Sunday, June 12, 2011
Set focus to Silverlight application and to a scrollviewer content
Wednesday, January 19, 2011
ICollectionView and CollectionViewSource
Thursday, November 05, 2009
Removing path point tangent in Expression Blend
For instance, you have a path created from a rectangle with corner radius and you want to make the bottom left and right corners have no roundness.
For this, select the point and with ALT down just click the point and the tangent should be removed.