cotzo-blog-blog
cotzo-blog-blog
Programming and "stuff"
4 posts
Don't wanna be here? Send us removal request.
cotzo-blog-blog · 14 years ago
Text
Assembly.Load in WPF -> headaches
For experienced programmers I'm sure this post will not bring anything new but I'm sure that many people came across this problem.
Scenario:
Have a WPF application in location A and the same one in location B. Start application from location A and try to get the information from the application in location B using Assembly.Load(path). I needed to do this for the updater module to check it's version, name etc. In the next second application A will crash because it can't find various resources because of the same namespaces allocation.
Solution:
Use Assembly.ReflectionOnlyLoadFrom(path) or you can use different domains for loading the second assembly. The first solution is better if you just need few reflection informations from that assembly. Of course if you intend to use that 2nd assembly you need to load it in a different domain: http://msdn.microsoft.com/en-us/library/25y1ya39.aspx 
12 notes · View notes
cotzo-blog-blog · 14 years ago
Text
An attempt was made to load an assembly with an incorrect format SGEN Error in Visual Studio
I came across this annoying error when trying to compile my solution for 64-bit. This occurs when a project references a webservice and also references a 64-bit assembly. If you have serialization set to Auto or On for the first assembly then this error will pop out so you need to turn serialization off.
18 notes · View notes
cotzo-blog-blog · 14 years ago
Text
WCF HTTPS self hosted service Certificate Installation guide
When hosting a WCF service in IIS the whole process of upgrading it to https is really easy but for a self hosted WCF service in a windows process or in any .net application you need to manually install the server certificates for https to work. What you need is to start visual studio command prompt and enter these 2 commands. 1. makecert.exe -sv SignRoot.pvk -cy authority -r signroot.cer -a sha1 -n "CN=AuthorityName" -ss my -sr localmachine this call will create the root certification authority in the local machine. Now we need to actually create the server certificate. 2. makecert.exe -iv SignRoot.pvk -ic signroot.cer -cy end -pe -n CN="localhost" -eku 1.3.6.1.5.5.7.3.1 -ss my -sr localmachine -sky exchange -sp "Microsoft RSA SChannel Cryptographic Provider" -sy 12 this call will create the actual server certificate needed for https channel to work. This certificate will work only when you host the WCF service in localhost. When you move it to another machine or make it accessible on the network you need to call again the second makecert and at CN enter the ip of the machine. We have the certificate in place now but we need to map it to a custom port if you wish or the default 443 port. Use httpConfig (GIYF) and go to SSL and if in the list your address:port is not present go to Add and fill up the desired IP, port the Guid of the WCF App (found in AssemblyInfo.cs) and click browse to find the certificate created before. Then click OK, Apply and you can use the WCF service through a secure https service. If you have any questions regarding hosting the WCF Service just give me a shout UPDATE Some browsers won't allow access to a service if the expiry date is more than 2 years. That's why in the second makecert call you can also specify the expiry date: -e dd/mm/yyyy
http://www.stevestechspot.com/downloads/httpconfig.zip  
28 notes · View notes
cotzo-blog-blog · 14 years ago
Text
C# URL Regex pattern
I've found on the Internet a lot of patterns for Regex used to validate URLs but many of them had a lot of problems. Finally I've found the best validation method for URL. This is the code: string pattern = @"^(http|https|ftp)\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(:[a-zA-Z0-9]*)?/?([a-zA-Z0-9\-\._\?\,\'/\\\+&%\$#\=~])*[^\.\,\)\(\s]$"; Regex reg = new Regex(pattern, RegexOptions.Compiled | RegexOptions.IgnoreCase); return reg.IsMatch(Text);
11 notes · View notes