Link to home
Start Free TrialLog in
Avatar of Victor  Charles
Victor CharlesFlag for United States of America

asked on

Help with adding DLL file in Windows project

Hello,

A .NET project was converted to a DLL file to be used with another project. However when attempting to add the DLL file under the reference sections, I receive the following error: Events not supported on HWND based channels. I had no issue with VS2010, but seems to be an issue with VS2013/2015.

Thanks,

Victor
Avatar of Subrat (C++ windows/Linux)
Subrat (C++ windows/Linux)
Flag of India image

try changing the target configuration to any CPU, and also to other options if required while building the DLL.
Then try to add the reference
Hi Victor;

Is that the only information given on the error?
What .Net version was the dll built with?
What .Net version is the application built with?
Avatar of Victor  Charles

ASKER

Hi,

I'm running more test, will get back to you.

Thank You.

Victor
Hi,

I was able to link to the DLL but receiving error message:

An unhandled exception of type 'System.NullReferenceException' occurred in TestProject.dll

Additional information: Object reference not set to an instance of an object.

C1Screen1.Splits(0).DisplayColumns(i).Visible = False
   
,visble = False may not be recognized because the C1Screen1 is mentioned in other parts of the code such as:

            C1Screen1.Height = C1Screen5.RowHeight * 10 + 10
       
but no error occurs.

Any ideas how to fix this error?

Thanks,

Victor
Place a breakpoint on this line of code
.Splits(0).DisplayColumns(i).Visible = False

Open in new window

. When the breakpoint is hit move the cursor over each of the words C1Screen1, DisplayColumns(i) and Visible to make sure they have values.
Fernando,

The application works ok by itself, error only occurs when I use it as a DLL to reference from another project, it works with On error resume next, but don't know why .Visible = False causes an error when the application is referenced as a DLL.

Thanks,

Victor
Victor;

When you receive this exception, "Object reference not set to an instance of an object", it is saying that some object in this statement, C1Screen1.Splits(0).DisplayColumns(i).Visible = False, was NOT created before it was used. If you do what I asked in my last post we may be able to track down what is the issue. We are looking for those values when that line causes the exception not when it works.
Fernando,

 I put a breakpoint on that line using the original project but when I click on continue I don't see any values, screen goes to the code section.

My point was I'm not getting that  error when I run the application by itself, the error only occurs when I convert it into a DLL, for some reason The DLL does not work with .Visible = False when reference from  another application. Some of the columns contain blank values which maybe causing the error when converted to a DLL.

Thanks,

Victor
Victor;

You state the following, "My point was I'm not getting that  error when I run the application by itself, the error only occurs when I convert it into a DLL,", A couple of questions.
What is the original type of the application, Windows Form, a Console app or something else?
How do you convert it into a dll?
How do you call it from the application you use it in?
Hi Fernando,

Sorry for the late reply, just back home.

The original applications is a Windows Form. I converted it into a class library (DLL) using the application than added it in the reference section of another application and accessing it with the following code:

   Dim frm2 As New TestProject.Form1
   frm2.Show()

DLL seems  to have some limitation, for example Exit sub and Form.Visible = True returns in error when trying to create the DLL. I had to comment them out to create the DLL.

Thanks,

Victor
ASKER CERTIFIED SOLUTION
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Fernando,

I was not clear, the steps you mentioned is what I followed. The DLL was instantiated use from2. But I noticed  .visible doesn't work with a DLL.

Thanks,

Victor
Can you post the app that is the dll as a zip.
can you make a public member fuction in side the DLL to make the .visible to true. and call that function in your form2.
Hi,

Unfortunately I can't  post the file. How do you make a publ8c member function?

Thanks,

Victor
Where do you initialize the form that is in the dll which you are trying to set the property Visible on?
I initialize the form on the Form I am trying to access the DLL.
Please show the code you use in your exe to do this and identify the variable that is defined in the dll which is the Form in the dll that you are trying to set the property Visible in.
Fernando,

This is the only code I used to access the DLL.

for some reason .visible does not work but .close does.

Dim frm2 As New TestProject.Form1
frm2.Show()

Victor
Thank You.