473,407 Members | 2,676 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

code within libraries vs code within same project

What are some possible reasons for this:

I call a static method from a class within my assembly...works fine.
I call the same static method after it has been compiled into a different
assembly and referenced to my project....does't work. Give's me a "Object
not set to an instance...".

What are some possible reasons for this? I'm just giving the assembly a
strong name, compiling it into a dll and adding it as a reference into my
project. Why would this work any differently?
Nov 16 '05 #1
7 1182
oj
If the lib is referenced, you can call the static method via
<class>.<method>.

--
-oj
"melinda" <me*****@discussions.microsoft.com> wrote in message
news:D7**********************************@microsof t.com...
What are some possible reasons for this:

I call a static method from a class within my assembly...works fine.
I call the same static method after it has been compiled into a different
assembly and referenced to my project....does't work. Give's me a
"Object
not set to an instance...".

What are some possible reasons for this? I'm just giving the assembly a
strong name, compiling it into a dll and adding it as a reference into my
project. Why would this work any differently?

Nov 16 '05 #2
Can you show the code that declares the method, and the code that calls it?

--
Adam Clauss
ca*****@tamu.edu

"melinda" <me*****@discussions.microsoft.com> wrote in message
news:D7**********************************@microsof t.com...
What are some possible reasons for this:

I call a static method from a class within my assembly...works fine.
I call the same static method after it has been compiled into a different
assembly and referenced to my project....does't work. Give's me a
"Object
not set to an instance...".

What are some possible reasons for this? I'm just giving the assembly a
strong name, compiling it into a dll and adding it as a reference into my
project. Why would this work any differently?

Nov 16 '05 #3
melinda <me*****@discussions.microsoft.com> wrote:
What are some possible reasons for this:

I call a static method from a class within my assembly...works fine.
I call the same static method after it has been compiled into a different
assembly and referenced to my project....does't work. Give's me a "Object
not set to an instance...".

What are some possible reasons for this? I'm just giving the assembly a
strong name, compiling it into a dll and adding it as a reference into my
project. Why would this work any differently?


Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #4
Hi,

I bet your problem has nothing to do with the fact the type is in a dll,
most probably it's cause you are using some resource particular to the .exe
that is not accesible to the dll.
Are you using any Environment, AppSetting or something like that?

Take a look at the null object , in the Exception.StackTrace you will get
the line number of the error.

if this do not help just post the code

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"melinda" <me*****@discussions.microsoft.com> wrote in message
news:D7**********************************@microsof t.com...
What are some possible reasons for this:

I call a static method from a class within my assembly...works fine.
I call the same static method after it has been compiled into a different
assembly and referenced to my project....does't work. Give's me a
"Object
not set to an instance...".

What are some possible reasons for this? I'm just giving the assembly a
strong name, compiling it into a dll and adding it as a reference into my
project. Why would this work any differently?

Nov 16 '05 #5
Well, there was too much code to add but it is dying in this static method
that is located in the dll... I believe it dies when it calls
sf.GetFileName()....but not sure.

private static string Header()
{
// Create a StackTrace that captures
// filename, line number and column
// information, for the current thread.
// 2 stack frames up because we were called by the Log method,
which was
// called by the method we want info about.
System.Diagnostics.StackTrace st = new
System.Diagnostics.StackTrace(2, true);

// High up the call stack, there is only one stack frame
System.Diagnostics.StackFrame sf = st.GetFrame(0);

// remove all characters leading up to the last directory path
separator
string shortFileName = sf.GetFileName().Remove(
0, // Starting character
sf.GetFileName().LastIndexOfAny( new
char[]{System.IO.Path.DirectorySeparatorChar} ) + 1 // For this many
);

return string.Format(
"{0:T}, {1} {2}, {3}: ",
System.DateTime.Now,
shortFileName,
sf.GetFileLineNumber(),
sf.GetMethod());
}

"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

I bet your problem has nothing to do with the fact the type is in a dll,
most probably it's cause you are using some resource particular to the .exe
that is not accesible to the dll.
Are you using any Environment, AppSetting or something like that?

Take a look at the null object , in the Exception.StackTrace you will get
the line number of the error.

if this do not help just post the code

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"melinda" <me*****@discussions.microsoft.com> wrote in message
news:D7**********************************@microsof t.com...
What are some possible reasons for this:

I call a static method from a class within my assembly...works fine.
I call the same static method after it has been compiled into a different
assembly and referenced to my project....does't work. Give's me a
"Object
not set to an instance...".

What are some possible reasons for this? I'm just giving the assembly a
strong name, compiling it into a dll and adding it as a reference into my
project. Why would this work any differently?


Nov 16 '05 #6
apperantly the file names don't exist in the frame properties (in the
StackTrace Object) that belong to the dll. Kind of what you were saying
Ignacio. I'm not sure why though.

"melinda" wrote:
Well, there was too much code to add but it is dying in this static method
that is located in the dll... I believe it dies when it calls
sf.GetFileName()....but not sure.

private static string Header()
{
// Create a StackTrace that captures
// filename, line number and column
// information, for the current thread.
// 2 stack frames up because we were called by the Log method,
which was
// called by the method we want info about.
System.Diagnostics.StackTrace st = new
System.Diagnostics.StackTrace(2, true);

// High up the call stack, there is only one stack frame
System.Diagnostics.StackFrame sf = st.GetFrame(0);

// remove all characters leading up to the last directory path
separator
string shortFileName = sf.GetFileName().Remove(
0, // Starting character
sf.GetFileName().LastIndexOfAny( new
char[]{System.IO.Path.DirectorySeparatorChar} ) + 1 // For this many
);

return string.Format(
"{0:T}, {1} {2}, {3}: ",
System.DateTime.Now,
shortFileName,
sf.GetFileLineNumber(),
sf.GetMethod());
}

"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

I bet your problem has nothing to do with the fact the type is in a dll,
most probably it's cause you are using some resource particular to the .exe
that is not accesible to the dll.
Are you using any Environment, AppSetting or something like that?

Take a look at the null object , in the Exception.StackTrace you will get
the line number of the error.

if this do not help just post the code

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"melinda" <me*****@discussions.microsoft.com> wrote in message
news:D7**********************************@microsof t.com...
What are some possible reasons for this:

I call a static method from a class within my assembly...works fine.
I call the same static method after it has been compiled into a different
assembly and referenced to my project....does't work. Give's me a
"Object
not set to an instance...".

What are some possible reasons for this? I'm just giving the assembly a
strong name, compiling it into a dll and adding it as a reference into my
project. Why would this work any differently?


Nov 16 '05 #7
sorry for so many posts, but I still have one question....
Is this a bug in System.Diagnostics.StackTrace?
I call
System.Diagnostics.StackTrace st = new System.Diagnostics.StackTrace(2, true);
//at this point st.FrameCount is 4, although only 3 have filenames (All
frames that
//appear that are part of the .exe display properly, but the one's that are
part of
//the .dll do not appear to have all the info, particularly filename.
System.Diagnostics.StackFrame sf = st.GetFrame(0);
//now sf is the one without a filename, it's null, it happens to be the
first frame that is part of the dll.
sf.GetFileName(); // this throws an exception, becasue filename is null.

First off, why is filename not there? I'm building with debug on and not
optimized.
Second off, why is filename null? This seems like a bug, but I'm not an
expert on what's considered a bug.

"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

I bet your problem has nothing to do with the fact the type is in a dll,
most probably it's cause you are using some resource particular to the .exe
that is not accesible to the dll.
Are you using any Environment, AppSetting or something like that?

Take a look at the null object , in the Exception.StackTrace you will get
the line number of the error.

if this do not help just post the code

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"melinda" <me*****@discussions.microsoft.com> wrote in message
news:D7**********************************@microsof t.com...
What are some possible reasons for this:

I call a static method from a class within my assembly...works fine.
I call the same static method after it has been compiled into a different
assembly and referenced to my project....does't work. Give's me a
"Object
not set to an instance...".

What are some possible reasons for this? I'm just giving the assembly a
strong name, compiling it into a dll and adding it as a reference into my
project. Why would this work any differently?


Nov 16 '05 #8

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

Similar topics

67
by: Steven T. Hatton | last post by:
Some people have suggested the desire for code completion and refined edit-time error detection are an indication of incompetence on the part of the programmer who wants such features. ...
1
by: rajesh_krec | last post by:
Hello Everybody, I'm using Microsoft Visual Studio .NET 2003 (with Vc7 compiler) I have some 15 projects each of which generate a static library when i build the solution in release mode. ...
8
by: Huihong | last post by:
Please check out our newly released source code search engine here, http://www.codase.com e.g., search socket method call,...
2
by: Daniel Granatshtein | last post by:
I am writing for both Windows XP and Pocket PC an application that implements the same behavior. In the architecture design I am using several foundation libraries for better code reuse. The...
0
by: MPadovani | last post by:
It's tricky setting up a .NET project that wraps around unmanaged C++ code, but if you set your project settings, it will work. I spent many days working out the right settings. My VS-2003 project...
2
by: lukegregory | last post by:
Is it possible to open a form from one project from a form in another project within the same solution? If so how is this done? Thanks
6
by: Mr Flibble | last post by:
Hi all, I've decided to use log4net for my logging/tracing. In the example on the site it shows using main() to setup the root logger and then using the LogManager within your classes to...
2
by: Jeff Dege | last post by:
I'm working with a group that's been doing C++ coding for quite a long time, now, and in that environment we've pretty much worked out development practices that serve us well. We've been doing...
1
by: eliben | last post by:
Hello, At the moment, I place all the code of my project in a src/ directory, and all the tests in a sibling tests/ directory, so for instance a sample project can look like this: doc/ ......
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.