简体   繁体   中英

Add Connected Service to nuget package

I used visual studio to create ac# class library. This library is basically just a container for a helper class that accesses a soap API. In order to interact with the soap API, I added a connected service in visual studio.

To recap: myLibrary >HOLDS> helperClass >REFERENCES> Connected Service >CALLS> SOAP API

The reason I put my helperClass is in a library is because I need to use this code in another project. (the destination project is a UiPath project FYI)

Then, I created a nuget package from this library and that is how I will import it into my destination project.

So now I have a Library of portable code that can interact with a soap API. EXCEPT it can't because the nuget package does not recognize the connect service.

This is the error that I get when I try to create an instance of my helperClass inside my destination project:

System.InvalidOperationException: Could not find default endpoint element that references
contract 'TMSDataService.TMSDataServiceSoap' in the ServiceModel client configuration
section. This might be because no configuration file was found for your application, or
because no endpoint element matching this contract could be found in the client element

I added the my nuget package originally only had the .dll file, but once I saw the error, I added the .dll.config file. It's still throwing the same error though.


I did some research to figure how I can add my connected service to my nuget package. (← this is the main problem)

After not a whole lot of luck, I determined that I can't really add this service to my nuget package. I am open to the idea of create a new nuget package just for the service, but I don't think that is possible either.

What is my best option? Is there a way to use the service in nuget package?

Add an App.config into a project consuming the nuget package with the service configuration. And just make sure the file is configured to be copied to the build directory.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM