473,671 Members | 2,566 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Accessing a C# delegate used in a C# interface....

Hello,

I'm currently developing on a large project where several assemblies
build into DLLs that support the final .NET EXE. The original plan was
to implement the project in VB.NET, so the EXE project is a VB WinForms
App. Later on we got approval to not stick to that requirement so I
started writing library code in C# (which I much prefer).

Of interest in my problem are two C# DLL projects aside from the main
EXE project. The first, we'll call it 'A', contains a code file with a
few general no-arg delegate declarations. Then, an interface in the
other C# project, which we'll call 'B', contains declarations of events
using this delegate-type.

Finally, one of the Forms in the VB EXE implements this interface and
thus implements the events from the C# interface in assembly B. This
seemed to work okay earlier and not give any errors, but perhaps other
errors that I have since resolved were blocking the notification of
these errors, so the problem could have been there all along since I
started using the delegates/interfaces. I'm not entirely sure on that.

If I build assembly A or B separately, I get no problems. They compile
entirely. Remember that the interface in B, uses the delegate in A, so
it can see it and use it fine according to the C# compiler. Then I try
building the VB EXE and it complains, saying

C:\MyPath\MainF orm.vb(16707566 ): Type 'A.EventHandler ' is not defined.

Obviously my code is not that long. The vb compiler made up that line
number, presumably as some default abstract designation. I'm not for
sure.

Yet I am not getting an error that says I am failing to implement the
interface. This is curious because the only way it can know that I am
correctly implementing the interface is if it knows about that
delegate-type. Before I fixed other problems, I was getting a compiler
error that told me I wasn't yet implementing the interface when I was
mismatching on some of the declarations between VB and C#. Once I fixed
those, those went away. So that error was accurately reflecting that
issue. So what could have occurred that it suddenly doesn't find a
declaration that had to have been used to help resolve another error
message?

All dependency references are project references (as opposed to
explicit DLL path references) and yes I've tried deleted all bin/obj
folders and then rebuilding.

Thanks.

/S

Nov 21 '05 #1
4 1572
Just an off the wall comment. What is the versioning in the
AssemblyInfo.vb set to? Is it set to auto increment the version?
Could this be related to your problem?

Nov 21 '05 #2
If by "auto increment" you mean that the version ends with a wildcard,
then yes. In AssemblyInfo.vb I have:

<Assembly: AssemblyVersion ("0.4.0.*")>

Does it matter that I've pushed the wild-card to the fourth component,
instead of the default third often used? I do this so I can explicitely
specify major-minor-micro versions and just let that final
auto-component be my IDE-generated "build-number".

How would this cause the problem I describe above though? Thanks.

/S

Nov 21 '05 #3
My idea is that perhaps the error you are getting is caused by a
mismatched version. I have read in Jeffrey Richter's book, "Applied
Microsoft .Net Framework Programming" that using the wildcard to
specify the version can cause dependency problems and that you should
always specify all four values.

I don't know if this is your problem, but it may be worth looking at.

Chris

Nov 21 '05 #4
Unfortunately this is not it. I deleted all build output again, removed
all wildcards from versions, specifying all parts explicitely, and the
result hasn't changed. Thanks for the suggestion though, I would agree
it was worth trying, seeing as how I can make little more sense of what
I'm experience.

So I'm open to other possibilities again. Thanks.

/S

Nov 21 '05 #5

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

Similar topics

1
404
by: serge calderara | last post by:
Dear all, I have a VB.NET application which is able to identify and load dynamically other dll's. created for my application. Those dll's are working as plugins for my main application. I need to used Delegate type for my plugins and then rehister to that delegate from my main application. I delcare my DElegate type as follow :
3
8877
by: Phill | last post by:
When should you use an interface over a delegate? Like if you have a class that needs to sort various types of objects. Should it use a delegate to do the sorting or require that the objects implement a sorting interface? I read that delegates are smaller and of finer granularity than interfaces. What does that mean exactly? Does it mean they are more efficient?
2
1733
by: Ruediger Klaehn | last post by:
I have written an arithmetic expression compiler. Now that it is finished I would like to give it a nice interface. Currently I have this interface: delegate double Function(double x); class ArithmeticExpression { public static Function Compile(string text); ... }
0
2495
by: Wavemaker | last post by:
One of the things I've struggled with from time to time is handling events raised on different threads. For example, an object could be listening to events from one or more objects running in different threads besides itself. There is a concern for thread safety. There are various ways of dealing with this. One way is to make the class thread safe by putting in locks. But another way is to stream the events from the various threads into a...
8
3554
by: Mike Caputo | last post by:
In VB.NET, need to be able to access certain properties on my main form from other forms. These are properties that may be changed by the user, so I have to be able to get to them throughout the application. How can I access the current instance of a specific Form object? For example: Class frmOne ....... Public Readonly Property XYZ() as String Get
4
2009
by: ^MisterJingo^ | last post by:
Hi all, I've been trying to get my head around delegates. The book i'm using had a single example, not much explaination, and didn't show how to set up a delegate and pass variables in and out of the functions it refers to. So I've been playing around and came up with he following code. I know it doesn't do much, but I just wanted to fit together delegates and parameter passing: //////////////// Code start
5
29796
by: atwomey | last post by:
When I try and place a delegate in an interface, like this : public interface ITest { double foo(); delegate void bar(); } I get an error "delegates cannot declare types". What is it about a delegate that makes it incompatible in an interface. I know that an interface cannot have any implementation - is there some implementation
5
2143
by: RP | last post by:
I have a function to fill combo box items. I pass SQL query and combo box name as arguments. This function is located in another class. In my Form, I have declared a delegate to this function before the namespace as; public delegate void dFillItems(ObjectName as string, Query as string) On my Forms I have several combo boxes and get filled when they get focus. Is it proper to use delegate in this situation? Will it improve...
0
2026
by: Roger Stoller | last post by:
Hello. I have developed a COM object using ATL. It seems to work fine when accessing it from VB.NET most of the time. However, I want to use a delegate in VB to asynchronously run a method in one of the interfaces in my COM module (using Delegate.BeginInvoke()). The interface seems to be "junk" when accessing it from the delegated VB method. When called synchronously from the same thread using the Delegate.Invoke(), it seems to work...
0
8402
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8927
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...
1
8605
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6237
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
5703
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
4416
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2819
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
2062
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1816
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.