Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. Almost desperate, C# into C++, why not work?

Almost desperate, C# into C++, why not work?

Scheduled Pinned Locked Moved Managed C++/CLI
helpquestioncsharpc++visual-studio
17 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Nemanja Trifunovic

    Instead of adaoja wrote: HttpSoapContext* hsc; hsc->get_ResponseContext()->get_Attachments()->Clear(); put HttpSoapContext::get_ResponseContext()->get_Attachments()->Clear();

    A Offline
    A Offline
    adaoja
    wrote on last edited by
    #3

    Thank you Nemanja But, the problem is (as i wrote previously) not really that codesnippet but why I can´t make an instance of the HttpSoapContext-object. And why do I have to? In C# there is no need for a HttpSoapContext variable = new HttpSoapContext(); statement. If I use your codesnippet it works for the compiler but not when I run the project (much like when I use pointers like above). I get the error "Object not set to an instance..." and if I try to make an instance the compiler complains with C2512 "No deafult constructor available". This is what confuses me. With the highest regards :):) Daniel

    N 2 Replies Last reply
    0
    • A adaoja

      Thank you Nemanja But, the problem is (as i wrote previously) not really that codesnippet but why I can´t make an instance of the HttpSoapContext-object. And why do I have to? In C# there is no need for a HttpSoapContext variable = new HttpSoapContext(); statement. If I use your codesnippet it works for the compiler but not when I run the project (much like when I use pointers like above). I get the error "Object not set to an instance..." and if I try to make an instance the compiler complains with C2512 "No deafult constructor available". This is what confuses me. With the highest regards :):) Daniel

      N Offline
      N Offline
      Nemanja Trifunovic
      wrote on last edited by
      #4

      You don't need to make an instance. get_ResponseContext() is a static method. adaoja wrote: If I use your codesnippet it works for the compiler but not when I run the project (much like when I use pointers like above). I get the error "Object not set to an instance..." Would you show me exactly what code did you try to compile and what is the error you get?

      1 Reply Last reply
      0
      • A adaoja

        Thank you Nemanja But, the problem is (as i wrote previously) not really that codesnippet but why I can´t make an instance of the HttpSoapContext-object. And why do I have to? In C# there is no need for a HttpSoapContext variable = new HttpSoapContext(); statement. If I use your codesnippet it works for the compiler but not when I run the project (much like when I use pointers like above). I get the error "Object not set to an instance..." and if I try to make an instance the compiler complains with C2512 "No deafult constructor available". This is what confuses me. With the highest regards :):) Daniel

        N Offline
        N Offline
        Nemanja Trifunovic
        wrote on last edited by
        #5

        If you take a look at This MSDN article[^], you'll see that HttpSoapContext is a "utility" class that contain only two static members. You can't instantiate objects of that class.

        A 1 Reply Last reply
        0
        • N Nemanja Trifunovic

          If you take a look at This MSDN article[^], you'll see that HttpSoapContext is a "utility" class that contain only two static members. You can't instantiate objects of that class.

          A Offline
          A Offline
          adaoja
          wrote on last edited by
          #6

          Hi Nemanja I do understand that, but why can´t I run the program? Why do I at that line get a "Object not set to an instance" - error. It doesn´t make any sense to me. With the highest regards // Daniel

          N A 2 Replies Last reply
          0
          • A adaoja

            Hi Nemanja I do understand that, but why can´t I run the program? Why do I at that line get a "Object not set to an instance" - error. It doesn´t make any sense to me. With the highest regards // Daniel

            N Offline
            N Offline
            Nemanja Trifunovic
            wrote on last edited by
            #7

            Maybe get_ResponseContext() or get_Attachments() return null. Why don't you break this big line and check for null?

            A 1 Reply Last reply
            0
            • A adaoja

              Hello everyone! I hope that I won´t be kicked out for asking the same question again and again until I get it to work. But here goes: I´m developing a managed C++-web Service and my problem occured months ago when I tried to pass binary files as dataset between the client and the service. I then got the advice to use DIME and recently downloaded WSE 1.0 SP1. I read an example in C# and tried to convert the code to c++. But it don´t get it to work. C# DimeAttachment attachment = new DimeAttachment("application/octet-stream", TypeFormatEnum.MediaType, ms); HttpSoapContext.ResponseContext.Attachments.Clear(); HttpSoapContext.ResponseContext.Attachments.Add(attachment); C++ (I´ve tried this, and similar) DimeAttachment* attachment; attachment = new DimeAttachment("application/octet-stream", TypeFormatEnum::MediaType, ms); HttpSoapContext* hsc; hsc->get_ResponseContext()->get_Attachments()->Clear(); hsc->ResponseContext->Attachments->Add(attachment); This will compile, but when I run I get the error "Object not set to an instance.." on the ...->Clear(); row. If I then try to instance the object; HttpSoapContext* phsc = new HttpSoapContext(); or SoapContext* sc = new SoapContext(); i get the error C2512 "no deafult constructor" when I compile. What can be wrong? Are there som arguments missing; Intellisense doesn´t detect any. Are there some error in the config-files? With the very highest regards PS************************************************* Well actually, I also can´t get a C#-version to function. I downloaded Roman Kiss-example "Using WSE-DIME for Remoting over Internet" http://www.codeproject.com/cs/webservices/remotingdime.asp ...allthough I did everything according to the book I kept on getting the error .FileLoadException "The assembly manifest definition [name] does not match the assembly reference". DS**************************************************;);) Daniel

              I Offline
              I Offline
              igor1960
              wrote on last edited by
              #8

              I maybe out of sync on this one, but shouldn't you be using S prefix in String declaration? I mean: attachment = new DimeAttachment(**S**"application/octet-stream", TypeFormatEnum::MediaType, ms); "...Ability to type is not enough to become a Programmer. Unless you type in VB. But then again you have to type really fast..." Me

              1 Reply Last reply
              0
              • N Nemanja Trifunovic

                Maybe get_ResponseContext() or get_Attachments() return null. Why don't you break this big line and check for null?

                A Offline
                A Offline
                adaoja
                wrote on last edited by
                #9

                woops! That is true, they both return null. Now I´m even more lost. With the highest regards // Daniel:confused:

                A 1 Reply Last reply
                0
                • A adaoja

                  Hi Nemanja I do understand that, but why can´t I run the program? Why do I at that line get a "Object not set to an instance" - error. It doesn´t make any sense to me. With the highest regards // Daniel

                  A Offline
                  A Offline
                  Anthony_Yio
                  wrote on last edited by
                  #10

                  there are variety of static utility object in C# or C++.NET which you do not need to instantiate and to be used immediately. It is call static object. For example. //In Managed C++. It is call this way String *myString = System::Environment::CurrentDirectory; //In C#. It is call this way. Syntaxes are slightly different but objective //are the same which to the current working directory for your app. string myString = System.Environment.CurrentDirectory; You do not need to call System.Environment.CurrentDirectory = new System.Environment.CurrentDirectory(); It is a static object. Like in MFC 6.0, CDialog::OnOK(); Sonork 100.41263:Anthony_Yio

                  A 1 Reply Last reply
                  0
                  • A Anthony_Yio

                    there are variety of static utility object in C# or C++.NET which you do not need to instantiate and to be used immediately. It is call static object. For example. //In Managed C++. It is call this way String *myString = System::Environment::CurrentDirectory; //In C#. It is call this way. Syntaxes are slightly different but objective //are the same which to the current working directory for your app. string myString = System.Environment.CurrentDirectory; You do not need to call System.Environment.CurrentDirectory = new System.Environment.CurrentDirectory(); It is a static object. Like in MFC 6.0, CDialog::OnOK(); Sonork 100.41263:Anthony_Yio

                    A Offline
                    A Offline
                    adaoja
                    wrote on last edited by
                    #11

                    Thank you sir I do understand that and when I don´t instantiate the object HttpSoapContext the compiler doesn´t complain. The proble occurs when I try to run/debug the program. Then I get the response "Object not set to an ..." This I found very strange? Is there a bug somewhere? Do I need to make any other adjustment? With the highest regards :) // Daniel

                    A 1 Reply Last reply
                    0
                    • A adaoja

                      Thank you sir I do understand that and when I don´t instantiate the object HttpSoapContext the compiler doesn´t complain. The proble occurs when I try to run/debug the program. Then I get the response "Object not set to an ..." This I found very strange? Is there a bug somewhere? Do I need to make any other adjustment? With the highest regards :) // Daniel

                      A Offline
                      A Offline
                      Anthony_Yio
                      wrote on last edited by
                      #12

                      It could be the object is NULL or you did not call new. In managed world. Everything needs to be called new youClass(). There is no old object in managed world. (this line is a joke) :) Sonork 100.41263:Anthony_Yio

                      A 1 Reply Last reply
                      0
                      • A Anthony_Yio

                        It could be the object is NULL or you did not call new. In managed world. Everything needs to be called new youClass(). There is no old object in managed world. (this line is a joke) :) Sonork 100.41263:Anthony_Yio

                        A Offline
                        A Offline
                        adaoja
                        wrote on last edited by
                        #13

                        Thank you sir As I wrote before, the object is NULL, not very good. But what do I do? Remember that I´m a newbie. With the highest regards :):) Daniel

                        1 Reply Last reply
                        0
                        • A adaoja

                          woops! That is true, they both return null. Now I´m even more lost. With the highest regards // Daniel:confused:

                          A Offline
                          A Offline
                          Anthony_Yio
                          wrote on last edited by
                          #14

                          I guess you need to put a complete codes for ppl to study your problem. It could be just some typos or small problem. Like namespace stuff or anything. Having too short of explanation of your problem will only return less understandable answer. (i learn this from someone in codeproject) Sonork 100.41263:Anthony_Yio

                          A 1 Reply Last reply
                          0
                          • A Anthony_Yio

                            I guess you need to put a complete codes for ppl to study your problem. It could be just some typos or small problem. Like namespace stuff or anything. Having too short of explanation of your problem will only return less understandable answer. (i learn this from someone in codeproject) Sonork 100.41263:Anthony_Yio

                            A Offline
                            A Offline
                            adaoja
                            wrote on last edited by
                            #15

                            Sure sir. I´m using WSE 1.0 SP1 on Microsoft.NET framework 1.0 I have installed WSE 2.0, but I don´t get it to work. Here goes. //Create a new DimeAttachment class CString m_sFilepath = Server->MapPath("/.../.../"); CString m_sFilename(inFileName) ; // an incomming string FileStream *fs; try { fs = new FileStream(m_sFilepath + m_sFilename,FileMode::Open,FileAccess::Read); //copy stream to stream unsigned char sbuf __gc[]; sbuf = new unsigned char __gc[fs->Length]; fs->Read(sbuf, 0, sbuf.Length); MemoryStream *ms; ms = new MemoryStream(); //close file fs->Close(); //attach body DimeAttachment* da; da = new DimeAttachment("application/octet-stream", TypeFormatEnum::MediaType, ms); HttpSoapContext *hsc; hsc->get_ResponseContext()->get_Attachments()->Clear(); hsc->get_ResponseContext()->get_Attachments()->Add(da); } I can compile it but not run it, due to "Object not set to an instance" HttpSoapContext->ResponseContext->Attachments->Clear(); HttpSoapContext->ResponseContext->Attachments->Add(attachment); The above doesn´t work either. "Left of -> must point on a class/struct/union/" I have had the thread in ExpertsExchange http://www.experts-exchange.com/Programming/Programming\_Languages/Dot\_Net/Q\_20714751.html#9208316 With the highest regards // Daniel

                            A 1 Reply Last reply
                            0
                            • A adaoja

                              Sure sir. I´m using WSE 1.0 SP1 on Microsoft.NET framework 1.0 I have installed WSE 2.0, but I don´t get it to work. Here goes. //Create a new DimeAttachment class CString m_sFilepath = Server->MapPath("/.../.../"); CString m_sFilename(inFileName) ; // an incomming string FileStream *fs; try { fs = new FileStream(m_sFilepath + m_sFilename,FileMode::Open,FileAccess::Read); //copy stream to stream unsigned char sbuf __gc[]; sbuf = new unsigned char __gc[fs->Length]; fs->Read(sbuf, 0, sbuf.Length); MemoryStream *ms; ms = new MemoryStream(); //close file fs->Close(); //attach body DimeAttachment* da; da = new DimeAttachment("application/octet-stream", TypeFormatEnum::MediaType, ms); HttpSoapContext *hsc; hsc->get_ResponseContext()->get_Attachments()->Clear(); hsc->get_ResponseContext()->get_Attachments()->Add(da); } I can compile it but not run it, due to "Object not set to an instance" HttpSoapContext->ResponseContext->Attachments->Clear(); HttpSoapContext->ResponseContext->Attachments->Add(attachment); The above doesn´t work either. "Left of -> must point on a class/struct/union/" I have had the thread in ExpertsExchange http://www.experts-exchange.com/Programming/Programming\_Languages/Dot\_Net/Q\_20714751.html#9208316 With the highest regards // Daniel

                              A Offline
                              A Offline
                              Anthony_Yio
                              wrote on last edited by
                              #16

                              Could you divide your code so that it is like this SoapContext* sc = HttpSoapContext::ResponseContext; and then make sure your call is within [Web Method] function scope. Check out Consuming web service from Managed C++[^] Sonork 100.41263:Anthony_Yio

                              A 1 Reply Last reply
                              0
                              • A Anthony_Yio

                                Could you divide your code so that it is like this SoapContext* sc = HttpSoapContext::ResponseContext; and then make sure your call is within [Web Method] function scope. Check out Consuming web service from Managed C++[^] Sonork 100.41263:Anthony_Yio

                                A Offline
                                A Offline
                                adaoja
                                wrote on last edited by
                                #17

                                Thank you sir ... but this is old news, I have tried the diffenent codesnippets back and forth and now the problem isn´t the code. It is the WSE and DIME, and why I can´t make that work. I have uninstalled the WSE and reinstalled it (WSE 2.0) and still it points on WSE 1.0, I get an errormessage when I run it in the Fusion Log "File or assembly name Mirosoft.Web.Services or one of its dependencies, was not found." Do I need to make any changes in a config-file? I have tried changes in both web.config and machine.config, but I can´t get it to work. With the highest regards:) // Daniel

                                1 Reply Last reply
                                0
                                Reply
                                • Reply as topic
                                Log in to reply
                                • Oldest to Newest
                                • Newest to Oldest
                                • Most Votes


                                • Login

                                • Don't have an account? Register

                                • Login or register to search.
                                • First post
                                  Last post
                                0
                                • Categories
                                • Recent
                                • Tags
                                • Popular
                                • World
                                • Users
                                • Groups