[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.remoting

Re: RemoteException-Permission Denied

Ken Kolda

9/21/2004 5:55:00 PM

The problem stems from the fact that the SqlCommand and SqlConnection
objects are marhsal-by-ref objects. As a result, when you pass the
SqlCommand to your server, the object still lives on the client -- the
server just has a proxy. Similarly, when you set the connection for the
command prior to calling ExecuteReader, a proxy is created for the
SqlConnection object and passed back to the client.

Finally, when you call ExecuteReader(), that method call is actually
executed on the client. The SqlCommand object tries to use some internal
method(s) of the SqlConnection object to actually execute the command. Since
the SqlConnection object it has a reference to actually lives on the server,
you get the error described -- the SqlCommand object cannot call a
non-public method of the remote SqlConnection object.

To solve this, you will need to pass your query to the server in some form
other than a SqlCommand.

Ken


"billmac3" <billmac3@discussions.microsoft.com> wrote in message
news:5BADD862-8315-461B-A037-005F59A031C9@microsoft.com...
> I'm getting a RemoteException -' Permission Denied: can't call non-public
or
> static methods remotely' when trying to call sqlcommand.ExecuteReader
within
> a server method. the basic idea is that i'm trying to call into SQL server
> thru a remote server call and return either a data reader or datasaet to
the
> remote client..i pass a sqlcommand to the method which seems to work just
> fine in the server. the channel is working fine (binaryformat/TCP) even
tho
> the 2 processes are on the same machine..my connection to SQL server seems
OK
> also..i get this error when trying to get a result set from SQL server,
NOT
> returning one to the client..BTW, i'm using 1.1 of framework TIA