cancel
Showing results for 
Search instead for 
Did you mean: 

Connecttonewobject and connection to assembly

Former Member
0 Kudos

Just trying to clarify something...

I have created a VB.net assembly which connects to MS exchange for email/calendar purposes.

Using PB 12.5 I create an instance of an object, issue a connecttonewobject which is the DLL (assembly),

then connecting to exchange using user email id and password and retrieve and send emails with no issues.

Here's is where it gets messy..

IF I create a second instance of the object, issue a connecttonewobject to the same DLL but this time connect to exchange using a different user id and password then ... when I try to get emails from either instance of the object it is only looking at the connection of the user id that was last connected.

Basically I need to connect to exchange using the assembly with 2 different email accounts.  So I assumed if I create two instances of the object and connect that I would have two distinct connections.  Looks like when the second connection occurs it detects that the assembly is running and reuses it to connect to the second email account... in turn I lose the first email account connection.

Am I understanding this correctly or should I in-fact have two separate connections.

Do I need to have two distinctly named assemblies for this to work.. One for first user email account and a 2nd one for the other email account?

Thanks

Dave V.

(hope its not too confusing)

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Do you need to connect to Exchange with these two accounts CONCURRENTLY?  I can envision two users, one sitting on the other's lap, using the same computer and a single instance of the app, trying to retrieve their emails simultaneously...  

If that's not the user story, then just disconnect and DESTROY the oleobject instance before you instantiate and connect with the second one.  You'll essentially be single-threading your access to Exchange, but only one user is using your app at one time, right?

If you do need concurrent access, you'll need to ensure that your assembly is non-reentrant with the ThreadSafe pragma.  Then each instance will have their own Thread Local Storage.

-Paul-

Former Member
0 Kudos

Hi Paul,

That would be a "No" on the users siting on the lap situation.,..

I have users that have access to 2 different email accounts.  They have there own company account and also they work for the helpdesk which has its own account.  So for these particular users they need to connect to 2 accounts at the same time.  I ended up re-writing the assembly so that it can be logged into exchange with multiple accounts and so far it seems to be working, not sure if that would be the "standard/correct" approach or your suggestion of Threadsafe pragma would be the better approach.. any thoughts on that?   

Anyway thanks for the reply.

Dave V.

Answers (0)