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

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?
LVL 1
RodinaAsked:
Who is Participating?
 
Julian_KConnect With a Mentor Commented:
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
 
marconovaroCommented:

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
 
RodinaAuthor Commented:
marconovaro: I am not calling the assignment function from outside the .dll, but from a class in the same project.
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
RodinaAuthor Commented:
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
 
JMoon5FTMCommented:
Source code?
0
 
RodinaAuthor Commented:
[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
 
RodinaAuthor Commented:
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
 
Julian_KCommented:
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
 
marconovaroCommented:

[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
 
Da_WeaselCommented:
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
 
RodinaAuthor Commented:
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
 
Julian_KCommented:
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
 
Julian_KCommented:
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
 
RodinaAuthor Commented:
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
 
Julian_KCommented:
This was because of the new DOTNET.
Just give it a try, OK?
0
 
RodinaAuthor Commented:
What was because of .Net? Give what a try?
0
 
Da_WeaselCommented:
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
 
RodinaAuthor Commented:
.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
 
RodinaAuthor Commented:
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
 
CleanupPingCommented:
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
 
DanRollinsCommented:
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
 
RodinaAuthor Commented:
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
All Courses

From novice to tech pro — start learning today.