Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

i have created a custom web service in sharepoint which works fine, i am trying to use this web service in a user control but get missing assembly reference error, i have copied the webservice dll in GAC and done safe control entry, i have not done this before, please help me.

share|improve this question

2 Answers 2

UPDATED (In light of comments)

You just change the inherits parameter of your @ Control directive to point to a custom class (which inherits from UserControl) then delete the designer file and the class that VS added for you. You will lose the link between code behind and design view though so you will need to make Protected WithEvents variables for all your controls. Other than that you should be able to continue using your user controls and add a web reference as per any other VS project.

Same technique as AC uses for Pages here: http://www.andrewconnell.com/blog/articles/UsingCodeBehindFilesInSharePointSites.aspx

ORIGINAL ANSWER

Am I right in thinking that you just want to add a reference to a web service in Visual Studio?

Assuming your using Visual Studio 2008 then either right click your project and click on 'Add Web Reference' or if this is not visible then click on 'Add Service Reference' then click 'Advanced' then 'Add Web Reference'. You will then get the 'Add Web Reference' dialog which will allow you to enter the URL to your web service.

Clicking 'Add Reference' from here will then create a proxy class for the service in your project. You can then use this to call the service from your user control.

More info can be found here: http://msdn.microsoft.com/en-us/library/d9w023sx.aspx

share|improve this answer
    
I am using visual studio 2005, i know how to add a web refernce in visual studio project, but here in this case i am doing a user control for sharepoint so i will only be copying mycontrol.ascx and mycontrol.ascx.cs to a folder which is on the sharepoint server, i am working on a dev server to create this user control and will copy the user control manually to sharepoint server, my custom sharepoint web service is on the same server where i am going to copy my user control, can you help me how to do it? –  Anonymous Mar 4 '10 at 12:39
    
I don't know anything about SmartPart but if your copying the .cs file over to SP as well then I assume its being compiled on the fly, so no I have no idea how you would add a reference to a web service in this instance. Is there a reason that you cannot compile the code to a dll and deploy it? –  Charles Lee Mar 4 '10 at 13:24
    
I can compile it into a dll but for that i have to do a custom webpart instead of a usercontrol, it is not worth the pain doing a custom webpart unless there is a requirement of custom properties on the webpart, so i do user controls for sharepoint if there is no custom property involved, as doing user controls i get design view also which is not possible in custom web parts for sharepoint. –  Anonymous Mar 4 '10 at 13:29
    
Updated answer above. –  Charles Lee Mar 4 '10 at 14:28

You should use WSPBuilder to generate a project with a webservice.
WSPBuilder will aslo take care of deploying and adding it to safe controls. Then check if you can accesss yout webservice at http://{service-name}/{port}/_layouts/{YourService.asmx}

Example: http://localhost/_layouts/YourService.asmx

share|improve this answer
    
My custom web service is working fine from both _layouts and _vti_bin, i want to know how to reference and use a custom web service in a sharepoint user control. –  Anonymous Mar 3 '10 at 14:48
    
The process should be the same as in a stand alone project. What type of control are you trying to deploy? Have you tried deploying without the reference to eliminate the control as the problem? What steps have you taken? –  MBSurf Mar 3 '10 at 15:33
    
I have a user control say myusercontrol and i copy myusercontrol.ascx and myusercontrol.ascx.cs files to a custom folder where i store my usercontols and use a smart part to host my user controls. my user control works with ajax control tool kit and i am already using a autocompleteextender control with uses the same web service but in that case i just have to provide the servicepath to the control and it makes the call to the web servcie, now i have a requirement to call the web service through code to get data and display it, but cannot reference the web service, let me know how to do it. –  Anonymous Mar 3 '10 at 16:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.