Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3341294
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:42:22+00:00 2026-05-18T00:42:22+00:00

The Problem: I have a forms project which instantiates a class that is defined

  • 0

The Problem:
I have a forms project which instantiates a class that is defined in a separate dll project. When running the forms application which uses this dll everything runs perfectly fine, however, when I set a breakpoint to inspect objects of types that are defined in the dll project I get errors in my watch window.

Some things that may be important to know:

  1. The dll project uses unsafe and unmanaged code.
  2. This problem occurs before any unsafe functions are called.
  3. Unmanaged code debugging is enabled.
  4. I know the symbols are loaded for the dll.
  5. I know the version of the dll loaded by the debugger is the same used by the application.
  6. I have cleaned and deleted the output directory then rebuilt.
  7. They are using the same .NET version.

Example: if I were to add this to my watch window MyDllType.SomeProperty I would see this (in the watch window only):

'MyDllType.SomeProperty' threw an exception of type 'System.ArgumentException' Message: "Cannot find the method on the object instance."

However, if I were to add Debug.Writeline(MyDllType.SomeProperty); at that same exact point then I would get no exception and it would be correctly displayed in the output console.

Furthermore: if I were to create a list of a struct type defined in the dll project and add it to my watch window I would see this (in the watch window only):

// My Dll Project
public struct MyDllStruct
{
    public int x;
    public int y;
    public int z;
}

// Snippet from a function block in forms project
List<MyDllStruct> structList = new List<MyDllStruct>();

// Add a bunch of stuff to the list
// <-- Insert a breakpoint here
}

When i break and add structList to the watch window I get:

Unable to evaluate the expression. Operation not supported. Unknown error: 0x8004f0ed.

However, once again I were to add Debug.Writeline(structList.Count); at that same exact point then I would get no exception and it the count would be correctly displayed in the output console.

Full Example:

// My Dll Project
public class MyDllType
{
    public MyDLLType()
    {
        this.someProperty = 123456;
    }

    private int someProperty;
    public int SomeProperty
    {
        get{ return this.someProperty; }
        set{ this.someProperty = value; }
    }
}
public struct MyDllStruct
{
    public int x;
    public int y;
    public int z;
}

// My Forms Project
public class SomeController
{
    public SomeController()
    {
        this.dllType = new DllType();
        List<MyDllStruct> structList = new List<MyDllStruct>();

        // <-- For example, I get both aformentioned problems if i break here (or anywhere else these objects have been instantiated)
    }

    private MyDllType dllType;
}

As you could probably imagine, this is making it really hard to debug my application 🙂 Any help would be much appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T00:42:23+00:00Added an answer on May 18, 2026 at 12:42 am

    This is not an answer as such, but some insight into the Watch-window vs Debug-printout mystery.

    The Watch window in Visual Studio evaluates your input, say structList, using a built-in managed expression evaluator. As a runtime parser it is therefore a completely different beast than the compiler itself and only understands a subset of expressions. You can read a fine description of it here.

    Therefore it’s possible – and I seem to vaguely remember having experienced this myself – that this expression evaluator cannot properly handle types from an unsafe DLL. As a “lightweight compiler” it certainly does have some shortcomings, and this is possibly one of them.

    On the other hand, Debug.WriteLine() works fine because the expression passed to it is processed at compile-time by the C# compiler itself.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem in a Windows Forms application with Bitmap.Save failing when I
I have a problem with a ClickOnce deployment of a Windows Forms application. When
I have a little demonstration below of a peculiar problem. using System; using System.Windows.Forms;
Problem: I have an address field from an Access database which has been converted
Problem: I have two spreadsheets that each serve different purposes but contain one particular
Problem I have timestamped data, which I need to search based on the timestamp
Problem: We have a web app that calls some web services asynchronously (from the
Here's a problem I ran into recently. I have attributes strings of the form
Problem: I have to support users who need to edit web pages. Some of
I have problems with bringing a windows mobile 6 form to the front. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.