RaSor's Tech Blog

November 3, 2010

Miscellaneous VB6 and VBA upgrade

Filed under: VB6 — rasor @ 5:51 am

Links:

February 15, 2010

Com: HowTo call .NET from COM

Filed under: NET, VB6 — rasor @ 11:59 am

How do you register a .NET assembly for being callable from COM like from VB6?

Lets say you have a assembly called MyLib.dll.

Inside you have a namespace called MyNs.MyLib and a class called MyCls.

(more…)

December 18, 2009

ASP post to ASP.NET upgrade and encoding error

Filed under: Debugging, NET, VB6, Visual Studio — rasor @ 7:16 am

I wanted to debug some .NET code from an oldfashioned ASP page. the ASP page called a COM enabled .NET component using Server.CreateObject().
The ASP page received a form posting before the call to the component. 

If I replaced that serverside code with ASPX, then I instead could instanciate the .NET component through a “new MyNamespace.MyComponent()” instead of the “Server.CreateObject()”. By setting the posing ASP form as the startup url like http://mysite/myform.asp, I was then able to set a breakpoint in the new aspx page that received the form posting (myform_actions.aspx). The debugging could nicely continue in the .NET component. 

When you do this trick of upgrading the code for the received form post, there is a few things to consider: 

  • You need to reauthenticate in some way
  • The Session state from ASP is not shared with you ASPX session. You need to recreate any session variables in your ASPX session, if you need to use them in your migrated code.
  • Encoding of the form post needs to be done.

The migration worked fine and the debugging was a releave.
But initially I haven’t set the encoding. 

When the form post entered the myform_actions.aspx I could see (using Fiddler) that a posted “ø” was sent correctly as “%F8″, but it was tranlated to “?”, when read from Request(“MyTextInputCtrl”). 

There were some links telling me about the problem:

http://bytes.com/topic/asp-net/answers/491522-encoding-problem-when-posting-text-between-classic-asp-asp-net
http://www.w3.org/TR/html4/interact/forms.html#adef-accept-charset
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/gngrfGlobalizationSection.asp

The latter link fixed the problem:

<configuration>
   <system.web>
      <globalization
         requestEncoding="iso-8859-1"
         responseEncoding="iso-8859-1"/>
   </system.web>
</configuration>

The accept-charset I did not use. It probably is not understood in a HTTP/1.0 post.

The End.

October 17, 2008

VB6 ADO upgrade to .NET

Filed under: NET, VB6 — rasor @ 3:46 pm

For a start, before you upgrade your old solution to .NET you might consider to use ArtinSoft’s Visual Basic Upgrade Companion (VBUC) instead of the Visual Studio build upgrade. I have not tried it, but using it might make the following advices superfluous.

To ease the upgrade of VB6 it is possible to keep old VB6 ADO in .NET.
Microsoft has made some Primary Interop Assemblies (PIA’s) that are tweeked in a .NET way, so they are to prefer compared to generating them yourself. (more…)

Theme: Silver is the New Black. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.