WWF OwnershipTimeOut issue

Add Comment | Jan 13, 2009

http://social.msdn.microsoft.com/forums/en-US/windowsworkflowfoundation/thread/69c4b453-d331-491e-aab9-b7c1c8dae899/

 

New ASP.NET Charting Control

Add Comment | Jan 06, 2009

Signing an existing assembly

One Comment | Dec 19, 2008

If you want to sign an assembly, you must have the source code, then you can sign it by creating .Net Module.

1. Create .NetModule
    CSC /out:<OutputModule.netmodule> /t:module <CodeFile.cs>

2. Create a Keypair
    SN -k <KeyPairFile.snk>

3. Link Keypair with the assembly using Assembly Linker 
  
 AL /out:<OutputAssembly.dll> <Module.netModule> /keyfile:<Keyfile.snk>

There is a much simpler and easy way to do this, even if you do not have the source code.

ILMerge  is the answer:-
                Command:- ILMerge <Input.dll> /keyfile:<myKey.snk> /out:<Output.dll>

Manipulating ntext datatype in sql server

Add Comment | Nov 21, 2008

We have a table with ntext type of field in sql server database, that actually contains text data.
ntext is used to store the unicode type of data that that takes 2 times storage size in bytes,  is two times the number of characters entered.

Now the scenario is we would like to replace all occurances of a paricular string from the data with another string.

It is very simple to do with Replace command in Sql Server, but the constraint is it only takes varchar/nvarchar type of parameter i.e. we can not run Replace command over ntext, we need to cast/convert ntext into varchar/nvarchar but in that case there are chances of loss of data it can truncate the data while convering ntext into varchar/nvarchar.

UPDATETEXT is the suitable command to achieve this for ntext, it also include other binary type of data type image and text.

Following link is demonstration of UDDATETEXT for ntext datatype:
http://sqlserver2000.databases.aspfaq.com/how-do-i-handle-replace-within-an-ntext-column-in-sql-server.html

Above scenario is for SQL Server 2k only. If we have Sql Server 2k5, we should use varchar(max) and nvarchar(max) for text and ntext.
http://sqltips.wordpress.com/2007/05/28/use-varcharmaxnvarcharmax-instead-of-text-ntext/

 

How to use multiple versions of assembly

Add Comment | Nov 11, 2008

1. Create 2 shared assemblies with different versions (1.0.0.0 and 2.0.0.0).

2. For assembly 1 include the following reference in project file.
    <Reference Include="TestAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=508b5c5f7455410a, processorArchitecture=MSIL">
      <HintPath>..\..\TestAssembly\T1\TestAssembly.dll</HintPath>
      <Aliases>Test1</Aliases>
      <Private>False</Private>
    </Reference>

Hint Path Vs Reference Path
As for the "Referece Path" or "Hint Path" in the VS.NET project's setting
files, they're all design-time /dev-time setting used by the IDE. As
described in the IDE's help doc, "Reference Path" are used by the VS.NET
IDE to load all the assembliy references when the Project is loaded into
the VS.NET IDE. And the "Hit Path" is mainly used for building time, when
the IDE will build the project, it'll locate the assemblies which is
required to link through the "Hint Path". Anyway, they're all internally
used by the VS.NET IDE, and is possibly to change in sequential version and
they have nothing to do with the .NET framework CLR's runtime assembly
locating.

For .net framework CLR's runtime assembly locating, it'll follow a well
defined steps, generally, it'll check GAC (if strong-named) first, then,
codebase settting , and private path probing. Here is a MSDN reference
which describing the .NET framework's runtime assembly locating.

3. Form assembly 2 include the following reference in the project file.
    <Reference Include="TestAssembly, Version=2.0.0.0, Culture=neutral, PublicKeyToken=275b13b4e9b16f25, processorArchitecture=MSIL">
      <HintPath>..\..\TestAssembly\T2\TestAssembly.dll</HintPath>
      <Aliases>Test2</Aliases>
      <Private>False</Private>
    </Reference>

4. While refering the above assemblies set extern aliases for both the assemblies
      extern alias Test1;
      extern alias Test2;

5. And then we can use Test1 and Test2 as 2 different namespaces

      Test1.TestAssembly.
TestClass t1 = new Test1.TestAssembly.TestClass();
      MessageBox.Show(t1.Add(2, 3).ToString());

      Test2.TestAssembly.TestClass t2 = new Test2.TestAssembly.TestClass();
      MessageBox.Show(t2.Add(2, 3, 4).ToString());

Please note the project referencing both the assemblies will be compiled with the following warnings.

Warning 1 
No way to resolve conflict between "TestAssembly, Version=2.0.0.0, Culture=neutral, PublicKeyToken=275b13b4e9b16f25" and "TestAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=508b5c5f7455410a". Choosing "TestAssembly, Version=2.0.0.0, Culture=neutral, PublicKeyToken=275b13b4e9b16f25" arbitrarily. WindowsApplication1

Warning 2 
The referenced component 'TestAssembly' could not be found.

Above scenario is about when we refer both the assemblies of (same name different versions) in the same code file ..but what if we want to override the functionality of an assembly ver 1.0 with ver 2.0.

put following <runtime> tag under configuration settings in the aplication's config file.

<runtime>
<
assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<
dependentAssembly>
<
assemblyIdentity name="<assemblyName>" publicKeyToken="<publicKeyToken>" culture="<culture>" />
<!--<assemblyIdentity name="TestAssembly" publicKeyToken="5ce1b9763dbb3e84" culture="neutral" />->
<
bindingRedirect oldVersion="<oldVersion>" newVersion="<newVersion>" />
<!--<bindingRedirect oldVersion="1.0.0.0" newVersion="1.1.0.0" />-->
</
dependentAssembly>
</
assemblyBinding>
</
runtime>

CAMSTUDIO- Record Video

Add Comment | Nov 05, 2008

CAMSTUDIO A cool tool that lets you record a video of a section of your screen.  It saves to AVI format, though it also has a feature to convert to a SWF to embed it in a web page.  It’s opensource too. :)

 http://camstudio.org/

 

 

Docx to Doc conversion

2 Comments | Nov 04, 2008

 

The date in the certificate is invalid or has expired, MSXML error

Add Comment | Sep 24, 2008

Following code will display error: The date in the certificate is invalid or has expired. if the SSL cerificate on the server is expired.

set objHttp = Server.CreateObject("MSXML2.ServerXMLHTTP.3.0")
objHttp.Open "POST", "https://<POSTURL>", false
objHttp.send objRequest

We need to update the SSL certificate to get it work, we can also ignore the above error just by adding following highlightrd lines in the code, in that case communication will no longer be secure.

Const SXH_SERVER_CERT_IGNORE_ALL_SERVER_ERRORS = 13056
set objHttp = Server.CreateObject("MSXML2.ServerXMLHTTP.3.0")
objHttp
.setOption(2) = SXH_SERVER_CERT_IGNORE_ALL_SERVER_ERRORS
objHttp.Open "POST", "https://<POSTURL>", false
objHttp.send objRequest

.Net Videos

One Comment | Jan 23, 2008

Ravi launched the .Net Video site:- http://www.dotnetvideos.net/

Using Http PUT method for file upload

4 Comments | Jan 04, 2008

The PUT method not as widely used as the POST method is the more efficient way of uploading files to a server. This is because in a POST upload the files need to be combined together into a multipart message and this message has to be decoded at the server. In contrast, the PUT method allows you to simply write the contents of the file to the socket connection that is established with the server.

When using the POST method, all the files are combined together into a single multipart/form-data type object. This MIME message when transferred to the server, has to be decoded by the server side handler. The decoding process may consume significant amounts of memory and CPU cycles for very large files.
The disadvantage with the PUT method is that if you are on a shared hosting enviorenment it may not be available to you. we need to enable the PUT verb for the server extension

Enable PUT on IIS web server:-
=========================
1. Select Virtual Directory  2.=> Properties 3.=> Configuration 4.=> Under Mappigs Tab - select extension (e.g. .aspx)=> add PUT in verb list.

The fundamental difference between the POST and PUT requests is reflected in the different meaning of the Request-URI. The URI in a POST request identifies the resource that will handle the enclosed entity. That resource might be a data-accepting process, a gateway to some other protocol, or a separate entity that accepts annotations. In contrast, the URI in a PUT request identifies the entity enclosed with the request.

Sample Code:-   Following code sample will be used to test the PUT method for Uploading the file, here ASP and VBScript is used in the sample, I'm using XmlHttpRequest object for making HttpRequest and getting the HttpResponse back from the web server.
refernces:- http://upload.thinfile.com/docs/put.php

<%

 

@ language="VBScript" %>
<html>
<
head>
<title>Upload</title>

<script language="VBSCRIPT">dim strURL
Function sendit(sfileName, sType)
sData = getFileBytes(sfileName, sType)
'MsgBox(sData)
sfileName= mid(sfileName, InstrRev(sFileName,"\")+1, len(sfileName))
dim xmlhttp
set xmlhttp = Createobject("MSXML2.XMLHTTP.3.0")
'strURL = "http://localhost/TEST/" & sfileName
xmlhttp.Open "PUT", strURL, false
xmlhttp.Send sData
show.innerText=
"Status: " & xmlhttp.statusText
show1.innerText=
"Response: " & xmlhttp.responseText
set xmlhttp=Nothing
MsgBox("Done!! File Uploaded Successfully.")
End Function Function Send(sfileName, sType)
sData = getFileBytes(sfileName, sType)
'MsgBox(sData)
sfileName = mid(sfileName, InstrRev(sFileName,"\")+1, len(sfileName))
End FunctionSub showresult()
document.write
"<CENTER>Take A look!<BR/><A href=" & strURL & ">" & URL & "</a></CENTER>"
End SubFunction getFileBytes(flnm, sType)
Dim objStream
Set objStream = CreateObject("ADODB.Stream")
if sType="on" then
objStream.Type = 1 ' adTypeBinary
else
objStream.Type = 2 ' adTypeText
objStream.Charset ="ascii"
end if
objStream.Open
objStream.LoadFromFile flnm
if sType="on" then
getFileBytes = objStream.Read
else
getFileBytes = objStream.ReadText
end ifobjStream.Close
Set objStream = Nothing
End Function</script>
</
head>
<
body><form name="frmUpload" action="" method="post">
<!--WIRE FRAME DESIGN START-->
<table align="center">
<tr>
<td>
<input type="FILE" id="filedata"></td>
</tr>
<tr>
<td>
<input type="Button" value="Submit" onclick="Call sendit(filedata.value, filetype.value)"></td>
</tr>
<tr>
<td>
<input type="checkBox" id="filetype" checked>Type Binary (Uncheck for Type Text)</td>
</tr>
<tr>
<td>
<input type="button" value="SHOW IT" onclick="showresult()"></td>
</tr>
<tr>
<td>
<div id="show" align="center">
</div>
</td>
</tr>
<tr>
<td>
<div id="show1" align="center">
</div>
</td>
</tr>
</table>
</form>
</
body>
</
html>