Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

SharePoint Custom Web Services and SPWeb

  Asked By: Eddy    Date: Mar 26    Category: Sharepoint    Views: 1809

I have a custom web service deployed in WSS v.3. I have an ASMX file
pointing to a DLL in the GAC. I am attempting to associate a new user
with an existing SharePoint Group, but when I attempt to reference
SPWeb in the WebService class, I get the following error when I debug:

"Unable to evaluate expression because the code is optimized or a
native frame is on top of the call stack"

I know this is a generic message, but could someone help me? It seems
impossible to reference SPWeb within the web service.



1 Answer Found

Answer #1    Answered By: Kendrick Townsend     Answered On: Mar 26

I believe this is actually a security issue. I found a blog
that talks about a similar problem.

Once I wrapped my SPWeb references in a
SPSecurity.RunWithElevatedPrivileges delegate, the error  went away.

Web services  are different animals compared to web  parts, aspx pages,
etc that are deployed  to SharePoint sites. SharePoint hosts the web
services, but it is not fully aware of them (at least not to the same
degree as a web part). I can't get a SPContext to work either because
the code  is virtualized and not deployed within the content database.

If someone has a better understanding of this and could help  me
clarify this dilemma, I'd greatly appreciate it.

Didn't find what you were looking for? Find more on SharePoint Custom Web Services and SPWeb Or get search suggestion and latest updates.