?
Solved

Friend call within VB project doesn´t work on one installation

Posted on 2003-02-25
22
Medium Priority
?
603 Views
Last Modified: 2007-12-19
I have a VB project with one class holding a variable declared as Friend Property Set ProjectName(), and another class setting the value of that projectName. Since the classes are in the same project, this works fine.

I complie this into a .dll file, and the dll file works fine too.

Exept, on one of our windows server the .dll lauches an error basically saying that the friend function is not avaliable to the caller. I have added logging to the function, and I can see that the line that fails is the attempted assignment of a new value to the projectName property.

Since the .dll works fine on two machines, I have excluded a programming reason for this behaviour, and assume that it has to be some kind of windows configuration issue. But I have no idea where to start looking. Hints?
0
Comment
Question by:Rodina
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 10
  • 5
  • 2
  • +4
22 Comments
 
LVL 6

Expert Comment

by:marconovaro
ID: 8016504

This is the "normal" behaviour of Friend properties, functions and subs.

Let me exxplain: if you declare a friend property, you are going to tell the compiler that you want to use that function only in the project the class belongs to.
This means that you won't be able to call a friend function from outside, with an ActiveX DLL.

To do this (if you need), you have to change the declaration to:

Public Property Set ProjectName()

HTH
M
0
 
LVL 1

Author Comment

by:Rodina
ID: 8016562
marconovaro: I am not calling the assignment function from outside the .dll, but from a class in the same project.
0
 
LVL 1

Author Comment

by:Rodina
ID: 8016731
This might call for a more detailed explanation:

In the .dll there is one class with a custom datatype, lets call it timeUnit. timeUnit has a description variable which can be read by anyone (has a public get statement), but set only by a helper function (description has a friend set statement). The helper function is located in another class, but within the same project. The helper function is public, so it can be called from outside the .dll.

The error occurs WITHIN the helper function when it tries to set the description.

I wan´t to stress that this code works fine in the debugger, as well as on three separate servers. But on one particular server this doesn´t work.

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Expert Comment

by:JMoon5FTM
ID: 8016920
Source code?
0
 
LVL 1

Author Comment

by:Rodina
ID: 8017042
[webTime.dll]
----timeRow.cls
Private iIndex As Integer
Private iProjectDisplayname As String
 ...
Public Property Get Index() As Integer
    Index = iIndex
End Property
Friend Property Let Index(newValue As Integer)
    iIndex = newValue
End Property

Public Property Get ProjectDisplayname() As String
    ProjectDisplayname = iProjectDisplayname
End Property
Friend Property Let ProjectDisplayname(newValue As String)
    iProjectDisplayname = newValue
End Property

----clsTimeRow.cls
Public Function saveTimeRow(ByVal tRow As timeRow, Optional makeCopy = False) As Integer
....various code to store in database.....
tRow.ProjectDisplayname = rst("PDescription")
...
End Function

[calling ASP page]
---weekTime.asp
set tr = server.createObject("webTime.timeRow")
set oTr = server.createObject("webTime.clsTimeRow")

oTr.saveTimeRow tr

---------------------------------

0
 
LVL 1

Author Comment

by:Rodina
ID: 8017079
When the oTr.savetimerow is executed the page throws an error. The error is passed on from the clsTimeRow.saveTimeRow function. I verified this by compiling an alternated dll that skips the line tRow.ProjectDisplayname=rst("PDesciption")

If I do that, execution works (but of course the function doesn´t do what it should.)
0
 
LVL 5

Expert Comment

by:Julian_K
ID: 8017982
Hi, Rodina.
1. If the error occurs in the tRow.ProjectDisplayName property:
In this line:
-->tRow.ProjectDisplayname = rst("PDescription")
Verify if rst("PDescription") does not return NULL value (if the field you are getting data from is empty)

2. If the error occurs when accessing the property, try the following:
-Declare the Let AND Get properties as FRIEND.
-Add new PUBLIC procedure to retrieve the value.

0
 
LVL 6

Expert Comment

by:marconovaro
ID: 8018029

[Fully OT]  ...sorry :)

Julian_K: here are points for you:

http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20516858.html

Let me close that.
M
0
 
LVL 3

Expert Comment

by:Da_Weasel
ID: 8021561
Is it possible that the Class it not registered properly on that machine.  There maybe a GUID issue thats is making the server at fault fail.  Have you tried removing all references to the library from this server and then reinstalling the library?
0
 
LVL 1

Author Comment

by:Rodina
ID: 8032313
Julian_K: The case is the first, it´s when setting the error occurs. I will look into this. Shouldn´t that return an error msg saying something about type mismatch or illegal use of null rather than an error with reference to the friend statement?

Da_Weasel: I think this has been tried, but we will try again.
0
 
LVL 5

Expert Comment

by:Julian_K
ID: 8032372
About the error message:
It COULD be something like "OLEDB Jet engine error etc...", but it is not necessary. Depends on your handling and other stuff.

Also, it depends on the error that happens ;) I mean it might be not the NULL value that is the problem, but something completely different.

Are you SURE you get the error on this line:
tRow.ProjectDisplayname = rst("PDescription") ??
0
 
LVL 5

Expert Comment

by:Julian_K
ID: 8032379
By the way, try the second variant. Somethimes (I can't remember when and why) I had similar problem and it appeared, that when exposing COM library to...(something), You can not use PUBLIC/FRIEND at the same time, although it works with VB.
0
 
LVL 1

Author Comment

by:Rodina
ID: 8033186
Julian_K:
The error message is:
---------------------------------------------
webTime error '800a0061'

Can not call friend function on object which is not an instance of defining class

/wt/SaveRow.asp, line 201
---------------------------------------------

I have inserted a check for null values, even thogh this is rarely the problem.

I am sure that the line stated is the one causing the problem, since I have loggin in my code. The log:s last entry is from the line before this one.

You idea that publishing of public/friend doesn´t work is a nice try, but if that was the case, why would my ASP code w. dll work fine on three other machines?

0
 
LVL 5

Expert Comment

by:Julian_K
ID: 8033404
This was because of the new DOTNET.
Just give it a try, OK?
0
 
LVL 1

Author Comment

by:Rodina
ID: 8033472
What was because of .Net? Give what a try?
0
 
LVL 3

Expert Comment

by:Da_Weasel
ID: 8034171
I think what he meant was to remove the .Net Framework from the machine and test it again....
I don't think this would matter though since the .Net Framework is all seperate from Win32 libs....
0
 
LVL 1

Author Comment

by:Rodina
ID: 8034199
.Net framework isn´t installed and never has been on the server that is messing with us. (It is avaliable on the ones where it works however.... I don't see any connections here?)
0
 
LVL 5

Accepted Solution

by:
Julian_K earned 300 total points
ID: 8040358
Nonono, I don't mean to Remove the .Net Framework.
What I wanted to say was that this problem occured becouse .Net (and as far as I can remember C++ also) doesn't like implementation like this: to have Public Get and Friend Set/Let. I sugested to implement both properties as Friend and then add a Public function to expose the value of the property.
0
 
LVL 1

Author Comment

by:Rodina
ID: 8040600
Julina_K: The .dll is already tested and refernced from some 3000 lines of code. I can´t go about changing property names now, it is a bit late for that. I need the reason that different windows machines gives the .dll different rights.

I'm starting to think maybe I should move this question to an OS-focused board instead...
0
 

Expert Comment

by:CleanupPing
ID: 8901138
Rodina:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 8972784
Rodina, an EE Moderator will delete this for you.
Moderator, my recommended disposition is:

    DELETE this question (refund points).

DanRollins -- EE database cleanup volunteer
0
 
LVL 1

Author Comment

by:Rodina
ID: 8974666
This issue was actually never resolved. With the wisdom of time I do however think that Julians interface-based solution would have been excellt, had I understood it properly at the time.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month12 days, 4 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question