C # How to distinguish data type?

I hope some of you guys can help me with this problem ....

I have a class library containing, among other things, 1 complex class. this class library is used in two other projects in the solution. 1 = Console application, 2 = Web service application (website application).

In the console application, I created a link to the asmx web service, which passes my complex class as parameter 1 in a method call.

The class is of type: ScheduleSummaryTransport

The function that performs the work in the console application expects the object to be associated with the class library DLL, and not with a link to a web service. However, the web service call expects a parameter of type ... from the web service directory.

So how can i do

ClassLibrary.ScheduleSummaryTransport → WebService.ScheduleSummaryTransport?

I tried:

wsReporting.SendReportSummary( (Reporting.ScheduleSummaryTransport) scheduleSummary);

But in the visual studio a development-time error was detected: it is impossible to express an expression .....

Please help and thanks

Update

For completeness, more code:

/// <summary>
        /// Sends the schedule report via email.
        /// </summary>
        /// <param name="scheduleSummary">
        /// The schedule summary.
        /// </param>
        private static void SendScheduleReport(ScheduleSummaryTransport scheduleSummary)
        {
            if (!Convert.ToBoolean(ConfigurationManager.AppSettings["EmailSummary"]))
            {
                return;
            }

            Trace.WriteLine(string.Empty);
            Trace.WriteLine("Sending summary by email... please wait ");

            Reporting.Reporting wsReporting = new Reporting.Reporting { Timeout = -1 };
            wsReporting.SendReportSummary( (Reporting.ScheduleSummaryTransport) scheduleSummary);
            Trace.WriteLine("Done...");
        }
+3
source share
3 answers

The WebService proxy generator (wsdl.exe) generates a class for storing all information about objects transmitted through the web service. This new class conflicts with the class specified in the client.

. ( ). Reference.cs Webservice Reference, . using ClassLibrary , .

. =)

+4

, . String MemoryStream - ? , , .

, . , . , - .

+3

I still don’t understand why you have two different versions of the same class, but if you can’t get to where you reference and use the version in the class library in both places, you can check Automapper to handle the display from the same version to another.

0
source

Source: https://habr.com/ru/post/1736306/


All Articles