473,729 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Shared methods derrived from interface

Hello, question,

I want to make a COM-compatible .NET DLL (Visual Basic). For this I need an
interface. The DLL has a class that must contain methods that can be used
without making an instance of the class first.

So I have a class that has methods that derrive from an interface, and the
same class has methods that are Shared....but methods that are derrived from
an interface are not allowed to be Shared...

How to solve this? Any Tricks. Somewhere I read that this rule does not
apply to classes that are NotInheritable, but it doesn't work.

Any help would be great,

me.

Nov 21 '05 #1
2 2632
Well, it's Friday, and it looks like the regulars around here vanished early.
I have limited experience with interfaces, but I'll take a shot at it since
you have not gotten a response yet.

I have 3 ideas:

1) If you implement a member from the interface, it cannot be shared. OK.
But if the same function could be morphed with a different signature,
probably by changing or adding a parameter, you could have a shared version
of the function in addition to the one required by the interface.

Public Function CleanMyHouse() as Integer Implements theClass.CleanM yHouse
'...
End Function

Public Shared Function CleanMyHouse(Sh ared as boolean) as Integer
'Ignore the parameter
'...
End Function

2) You can add members to a class that are in addition to the interface.
Similar to the above solution, but use different function names.

3) You could implement the interface, then remove references to the
interface, then allow members to be shared. This would not be a strict usage
of the interface, but might resolve the problem.

I am not sure about the COM requirements, so not sure if any of this will
work.

www.charlesfarriersoftware.com

"Elephant" wrote:
Hello, question,

I want to make a COM-compatible .NET DLL (Visual Basic). For this I need an
interface. The DLL has a class that must contain methods that can be used
without making an instance of the class first.

So I have a class that has methods that derrive from an interface, and the
same class has methods that are Shared....but methods that are derrived from
an interface are not allowed to be Shared...

How to solve this? Any Tricks. Somewhere I read that this rule does not
apply to classes that are NotInheritable, but it doesn't work.

Any help would be great,

me.

Nov 21 '05 #2
Thank you Charlie,

if I understand correctly, the first two solutions require different
functions with the same functionality. That is out of the question. There
may be only one implementation. I had a similar solution ( normal shared
methods and a seperate class with an interface for COM which call those
methods ), but I hope there is a better way.
I think I don't understand option 3, but if I do, it won't help me.

But thanks again for the response,

me.
"Charlie" <cfarrier at charlesfarriers oftware.com> wrote in message
news:4D******** *************** ***********@mic rosoft.com...
Well, it's Friday, and it looks like the regulars around here vanished early. I have limited experience with interfaces, but I'll take a shot at it since you have not gotten a response yet.

I have 3 ideas:

1) If you implement a member from the interface, it cannot be shared. OK. But if the same function could be morphed with a different signature,
probably by changing or adding a parameter, you could have a shared version of the function in addition to the one required by the interface.

Public Function CleanMyHouse() as Integer Implements theClass.CleanM yHouse
'...
End Function

Public Shared Function CleanMyHouse(Sh ared as boolean) as Integer
'Ignore the parameter
'...
End Function

2) You can add members to a class that are in addition to the interface.
Similar to the above solution, but use different function names.

3) You could implement the interface, then remove references to the
interface, then allow members to be shared. This would not be a strict usage of the interface, but might resolve the problem.

I am not sure about the COM requirements, so not sure if any of this will
work.

www.charlesfarriersoftware.com

"Elephant" wrote:
Hello, question,

I want to make a COM-compatible .NET DLL (Visual Basic). For this I need an interface. The DLL has a class that must contain methods that can be used without making an instance of the class first.

So I have a class that has methods that derrive from an interface, and the same class has methods that are Shared....but methods that are derrived from an interface are not allowed to be Shared...

How to solve this? Any Tricks. Somewhere I read that this rule does not
apply to classes that are NotInheritable, but it doesn't work.

Any help would be great,

me.

Nov 21 '05 #3

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

Similar topics

0
1127
by: Elephant | last post by:
Hello, question, I want to make a COM-compatible .NET DLL (Visual Basic). For this I need an interface. The DLL has a class that must contain methods that can be used without making an instance of the class first. So I have a class that has methods that derrive from an interface, and the same class has methods that are Shared....but methods that are derrived from an interface are not allowed to be Shared...
32
4522
by: Adrian Herscu | last post by:
Hi all, In which circumstances it is appropriate to declare methods as non-virtual? Thanx, Adrian.
14
6307
by: Joe Fallon | last post by:
I am trying to build a Data Access Layer for a SQL Server back end. My class has a number of methods in it. The constructor takes a connection string. I currently have to instantiate an object in order to use one of my methods. So I end up doing this quite a lot in my app. If I change all of the methods to be Shared does that mean I can just use them without instantiaing an instance of my DAL class?
4
3359
by: Rubbrecht Philippe | last post by:
Hi there, I would like to develop an interface that when implemented in a class requires a number of shared properties or methods to be available. It seems a Shared Member can not be used as interface member implementation?! Is there a workaround to this problem?! Best regards, Philippe Rubbrecht
7
9294
by: Iain Mcleod | last post by:
Hi This must be an often encountered problem. I want to declare an abstract class or an interface with nothing but several static constants so that I can use polymorphism when I call each of them from my code. My stab at the problem is shown below. Can anyone suggest what my most efficient workable solution would be (i.e. I don't want to have to create instances of the classes as they will only store constant information and I would...
9
1644
by: easy | last post by:
I start off with an interface class that has no data members and a handful of virtual functions. First Question: is that allowed ? I then derived from this class and it gets included into a couple of other classes that need that interface. The derived class had a number of data members including a struct that allow it to do its dirty work.
10
2645
by: Bryan | last post by:
I was trying to write an interface that would require the implementing class to have a shared function, CanAdd() as boolean, which decides if the current user can add a new instance of the particular class. This authorization is at the class level, not the instance level, so it should be shared, but I cannot find a way to require a class to implement a shared method via an interface. Any suggestions?
5
587
by: Sune | last post by:
Hi all, I want to make data stored in-memory (not disk) available to several processes. My concern is that poorly written C applications with dangling pointers may(will) damage the data in this memory segment if it is open to all, i.e. shared memory mapped into all processes memory area. I don't want to use TCP/IP client/server between the apps and a data store process due to the overhead.
11
3161
by: eBob.com | last post by:
I have this nasty problem with Shared methods and what I think of as "global storage" - i.e. storage declared outside of any subroutines or functions. In the simple example below this "global" storage is ButtonHasBeenClicked. In this simple example code in Form1 calls a routine in Module1 which then calls code back in Form1 (subroutine WhatEver). WhatEver needs to access ButtonHasBeenClicked but the reference to ButtonHasBeenClicked...
0
8921
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
9284
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9202
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,...
0
9148
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...
1
6722
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
6022
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
4796
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2683
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2165
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.