473,769 Members | 5,742 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cannot get past Object Reference Error

I have a question about a problem I am having with attempting to port
some old ASP code to ASP.NET.

We have a dll out there which we downloaded which creates GUIDs for
session management. In ASP, the function looks like this:

Function getGuid()
Dim sessionDUID
Dim MyGuid = Server.CreateOb ject("GuidMakr. GUID")
Dim mySession = Replace(MyGuid. GetGUID, "{", "")
MyGuid = Nothing
mySession = Replace(mySessi on, "}", "")
getGUID = mySession
End Function

Kind of hokey, but it was written by someone else, and for my purposes
it works just fine. However, I want to use the same functionality in
an ASP.NET framework. I have this exact same function in a class, but
I have modified it a little:
Function getGuid()
Dim sessionDUID
Dim MyGuid As New Object
MyGuid = Server.CreateOb ject("GuidMakr. GUID")
Dim mySession = Replace(MyGuid. GetGUID, "{", "")
MyGuid = Nothing
mySession = Replace(mySessi on, "}", "")
getGUID = mySession
End Function

and it blows up on this line:
MyGuid = Server.CreateOb ject("GuidMakr. GUID")

with this error:

Object reference not set to an instance of an object.

Exception Details: System.NullRefe renceException: Object reference not
set to an instance of an object.

Can someone give me some guidance? I'd appreciate it, thank you.

Danielle
However,

Mar 28 '06 #1
2 1941

First, I'd make the new asp.net version, return an actual type, not a
generic "object" (or variant as it used to be)

Function getGuid() as System.Guid
I'm not sure if you're trying to solve this generically, or if you want a
better dot.net way.
Function getGuid() as System.Guid
return new System.Guid.New Guid()
End Function

Function GetFriendlyGuid as string
return new
System.Guid.New Guid().ToString ().Replace("{", "").Replace("}" ,"").Replace ("-"
,"")
end function
Try those

The Server.CreateOb ject was asp specific.

I would avoid this syntax in asp.net at all costs.

If you must use some backend COM object, add them via "Add Reference" and
declare and instantiate them explicitly.

dim abc as GuidMakr.GUID = new GuidMakr.GUID()
abc.DoSomething ()

like that... (after adding the reference to the COM object)

...
<da************ ****@gmail.com> wrote in message
news:11******** *************@v 46g2000cwv.goog legroups.com...
I have a question about a problem I am having with attempting to port
some old ASP code to ASP.NET.

We have a dll out there which we downloaded which creates GUIDs for
session management. In ASP, the function looks like this:

Function getGuid()
Dim sessionDUID
Dim MyGuid = Server.CreateOb ject("GuidMakr. GUID")
Dim mySession = Replace(MyGuid. GetGUID, "{", "")
MyGuid = Nothing
mySession = Replace(mySessi on, "}", "")
getGUID = mySession
End Function

Kind of hokey, but it was written by someone else, and for my purposes
it works just fine. However, I want to use the same functionality in
an ASP.NET framework. I have this exact same function in a class, but
I have modified it a little:
Function getGuid()
Dim sessionDUID
Dim MyGuid As New Object
MyGuid = Server.CreateOb ject("GuidMakr. GUID")
Dim mySession = Replace(MyGuid. GetGUID, "{", "")
MyGuid = Nothing
mySession = Replace(mySessi on, "}", "")
getGUID = mySession
End Function

and it blows up on this line:
MyGuid = Server.CreateOb ject("GuidMakr. GUID")

with this error:

Object reference not set to an instance of an object.

Exception Details: System.NullRefe renceException: Object reference not
set to an instance of an object.

Can someone give me some guidance? I'd appreciate it, thank you.

Danielle
However,

Mar 28 '06 #2
It seems to me you probaby don't need to use that old COM object that's
giving you these problems. GUID features are built into the .NET framework.
To create a new guid, try this code:
Dim MyGuid as GUID = New GUID()

Here's more info:
http://msdn.microsoft.com/library/de...classtopic.asp

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
<da************ ****@gmail.com> wrote in message
news:11******** *************@v 46g2000cwv.goog legroups.com...
I have a question about a problem I am having with attempting to port
some old ASP code to ASP.NET.

We have a dll out there which we downloaded which creates GUIDs for
session management. In ASP, the function looks like this:

Function getGuid()
Dim sessionDUID
Dim MyGuid = Server.CreateOb ject("GuidMakr. GUID")
Dim mySession = Replace(MyGuid. GetGUID, "{", "")
MyGuid = Nothing
mySession = Replace(mySessi on, "}", "")
getGUID = mySession
End Function

Kind of hokey, but it was written by someone else, and for my purposes
it works just fine. However, I want to use the same functionality in
an ASP.NET framework. I have this exact same function in a class, but
I have modified it a little:
Function getGuid()
Dim sessionDUID
Dim MyGuid As New Object
MyGuid = Server.CreateOb ject("GuidMakr. GUID")
Dim mySession = Replace(MyGuid. GetGUID, "{", "")
MyGuid = Nothing
mySession = Replace(mySessi on, "}", "")
getGUID = mySession
End Function

and it blows up on this line:
MyGuid = Server.CreateOb ject("GuidMakr. GUID")

with this error:

Object reference not set to an instance of an object.

Exception Details: System.NullRefe renceException: Object reference not
set to an instance of an object.

Can someone give me some guidance? I'd appreciate it, thank you.

Danielle
However,

Mar 28 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
50588
by: Alex Ang | last post by:
I have written the following VBScript program. It is stored into a file "map_drive.vbs". It successfully mapped to a network drive \\server1\data. Dim WshNetwork Set WshNetwork = WScript.CreateObject("WScript.Network") sPwd = inputbox("Enter password") WshNetwork.MapNetworkDrive "J:", "\\server1\data", false, "xyz_net\John", sPwd Msgbox "Drives has been map successful"
8
775
by: Carel Lotz | last post by:
H We have ported our VB 6 application into VB .NET but are still integrating with a few COM + applications written in VB6 running on our application server (Win 2000 Server). We have the proxies to link to the application server installed but we every now and then get a error when we try to make a call to a component running on the app server. The error message is something like Object reference not set to an instance of an objec at...
8
5481
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- Hello, I have a very simple problem but cannot seem to figure it out. I have a very simple php script that sends a test email to myself. When I debug it in PHP designer, it works with no problems, I get the test email. If
1
1175
by: needin4mation | last post by:
Hi, I am using C# in asp.net. I have my treeview control from my built ..dll on my toolbox. I can drop it on the webpage. What I cannot do is reference treeview objects from the codebehind form. I can see: protected Microsoft.Web.UI.WebControls.TreeView TreeView1; But as soon as I try something like:
9
41963
by: David | last post by:
I am getting the following error during run-time compilation or a rebuild all of my application: error BC30311: Value of type 'mynamespace.x' cannot be converted to 'mynamespace.x' This occurs in only one component/project that accesses the 'x' object whereas several other components/projects also use the 'x' object in several other locations in exactly the same way without any problems. If I Rebuild
0
1869
by: JGKjr | last post by:
I have a Web Application written in C#. I am trying to call a web service method and recieve the error: System.InvalidCastException: Cannot assign object of type System.Boolean to an object of type System.String. I am able to call other methods within the same web service but not this one. Here is the generated code for this method after adding the Web Reference:
8
1882
by: wASP | last post by:
Hi, I'm having a problem referencing the elements within an object after a method of that object (a member function) has been activated with an onsubmit handler: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <script language="javascript" type="text/javascript"> function js_onsubmit_hndl_fn () {
1
18202
by: Marc | last post by:
Hi! I'm working with a C# client that calls a php web service. I've created a wrapper to call the service using .NET wsdl tool (adding a web reference). The call to the server works fine, it is serialized correctly, and the server returns a response (I've captured the response and it's correct!) but when the .NET deserialize this response, it throws the exception "System.InvalidOperationException: There is an error in XML
1
357
by: danielle.m.manning | last post by:
I have a question about a problem I am having with attempting to port some old ASP code to ASP.NET. We have a dll out there which we downloaded which creates GUIDs for session management. In ASP, the function looks like this: Function getGuid() Dim sessionDUID Dim MyGuid = Server.CreateObject("GuidMakr.GUID") Dim mySession = Replace(MyGuid.GetGUID, "{", "")
0
9586
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10210
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9861
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8869
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7406
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5446
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3956
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.