We have one service reference in one project of a solution. I am trying to move this service reference to new project in same solution. But adding the service reference in new project using URL present in the service reference of old project is throwing 404 error. I am not sure where is this service hence do not have it my IIS.
I tried to copy all the files and adding them to source control. like copy paste but then it has some auto generated code under reference.cs which generates all classes. They have old namespaces and might have to change it to new namespace manually. So, not sure if this can cause some other issue as I will be manually updating the auto generated code.
Is there a way to add this service reference in my new project?
option 1 - find the url by debugging the first project
Assuming that the first project accesses the WCF service correctly, you can debug it to the point where it makes the service call and look at the the remote address in the watch
var url = currentProxy.Endpoint.Address.Uri;
option 2 - add reference to the project thats already working
add a wrapper class that makes the WCF call in your original project and then add project reference of your original project to the new project. now you can you use the newly created wrapper to access the WCF service from the new project via the wrapper
Related
I have a WinForm project in Visual Studio 2017 where I have created a WCF endpoint reference from a service's wsdl file.
My project also uses several 3rd party dlls.
I want my project to be a standalone exe file that does not require installation, so I use ILMerge to package my dll files into a single exe file.
When running my compacted exe, I am getting exceptions about missing references to the WCF project endpoint:
Could not find default endpoint element that references contract in the ServiceModel client configuration section.
I tried looking up how to add WCF references via ILMerge, but I couldn't find anything relevant.
I also cannot find anything WCF related in my project's bin output folder.
My current usage of ILMerge is via cmd:
ILMerge.exe /t:winexe /out:target.exe /targetplatform:v4,<.net v4 path> output.exe dll1.dll ... dlln.dll
I am looking for a way to add the WCF references to the standalone exe via ILMerge, or locating the WCF reference outputs generated by Visual Studio in my project's bin out directory.
Solution
Following Abraham's comment, I found a way around the 'service reference' issue.
I used Svcutil.exe to generate the definitions to my service, and manually set the binding to it like so:
BasicHttpBinding myBinding = new BasicHttpBinding();
myBinding.Security.Mode = BasicHttpSecurityMode.Transport;
EndpointAddress myEndpoint = new EndpointAddress(SERVICE_URL);
SoapServiceClient client = new SoapServiceClient(myBinding, myEndpoint);
Now everything gets packed when using ILMerge.
By adding service reference, there are also some extra configurations generated in the configuration files. Therefore, it might cause the failure of packing the project. Alternatively, we manually copy the System.servicemodel section to the new project.
I suggest you change the way to consume the service. your project seems that you call the service by adding service reference. this will bring some other class libraries and references, which resulted that it is difficult to pack the project.
Please consider the below way to call the service.
https://learn.microsoft.com/en-us/dotnet/framework/wcf/feature-details/how-to-use-the-channelfactory
https://learn.microsoft.com/en-us/dotnet/framework/wcf/samples/channel-factory
it fully encapsulates the required class library in the main project.
Feel free to let me know if there is anything I can help with.
I had a solution that contained two projects, one for the web layer that also contained the models, and another for a Windows forms project that did some other "stuff". The forms project referenced the web project, and all was fine up until I needed to reference something from the web project in the forms project, which I could not do for circular reference reasons.
So I created a new solution, put the data layer in one project and the web layer in another, so later on I could add the third project, and put in the references I need. Now when I run the web project, I get the following error;
So I understand that the web project is struggling to find my namespace from the data project, but I have referenced it, so I don't know what more to do.
***EDIT
This comes as no shock, but it's the view that's the issue. If I edit my Index.cshtml, it recognises the referenced project. I tried adding;
#using LottoData.Models
and intellisense completed as I typed. However, when I run it now, I get;
Help!
This was my bad. I forgot to change the output type for the data project to "Class Library", it was still set to "Console Program". Changed that, removed and re-added the reference, cleaned and rebuilt and it works fine now. Thanks #David and #Armand for your input.
I found a way to copy a DLL reference from one project to another using VS Power Tools. Apparently it can't copy service references. Is there a way to do this manually?
The problem is that we cannot access the service right now. So we have to build the code without being able to add the service reference conventionally.
I am trying to add a web reference service in an ASP.net MVC project.
However when I add the service I got following error,
Custom tool error: Unable to import WebService/Schema. The object
'Settings' already contains a property
'FreeLance_Web_VATService_checkVatService' not of type
WebServiceUrl. C:\FINALBUILD\User Portal\User.Web\Web
References\VATService\Reference.map
Some How the designer.settings.cs had already a service referenced with the same. Once I changed the name of the service and added again, it started working.
I tried all of the above and I still experienced this issue. It turns out that a reference was stored in my app.config. I got rid of it and then re-added the web refences. That fixed the problem.
What you can do is remove the existing services and try to re-add the reference to the mvc application.Other thing is try to search with the 'FreeLance_Web_VATService_checkVatService' name in the settings.cs and see what it has. There should not be same name for the objects which will lead to this conflict
I had the same issue as I had copied the configuration from another file. I had to delete the configuration and update the web reference. When you add web reference settings is automatically added to the configuration file and hence you should not copy that part from another file. Remove and from your configuration file,update web reference and check if it is recreated.
i have few project that use the same wcf service, my asp.net and test project are working fine
with the wcf service i add.
my new project in mvc asp.net also added the wcf reference , all of those project reuse
the assemblies.
when there was compiler error with the types i saw difference in the reference.cs file and
the order that visual studio generate the code wasn't the same.
// CODEGEN: Parameter 'GetLookupTablesResult' requires additional schema information that cannot be captured using the parameter mode. The specific attribute is 'System.Xml.Serialization.XmlElementAttribute'.
this is the working one:
Runtime Version:4.0.30319.18063
this one not generate :
Runtime Version:4.0.30319.18444
why there is difference ? is it something in the solution settings?