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. .NET (Core and Framework)
  4. Must be simple question for .NET interop gurus here...

Must be simple question for .NET interop gurus here...

Scheduled Pinned Locked Moved .NET (Core and Framework)
questioncsharpc++htmldotnet
12 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.
  • I Offline
    I Offline
    igor1960
    wrote on last edited by
    #1

    OK, I have basic and probably simple question for you guys... Here is the situation: Assuming: 1. I have WinForm Control ("UserControl1") sitting on HTML page, let's assume his name on HTML layout is "ctrl"; 2. I have property of that control named "Object" that has set method; 3. My HTML script does the following: ctrl.Object = ctrl I'm setting Object property back to the value of "this" on the site of the control. So, basically, i understand that .NET class through RCW get's converted to IDispatch and then this IDispatch (probably with new CCW) get's passed back to the control. Now, it's not surprising that after that trip I'm getting public object Object { set { m_object = value; < } at <> m_object of type "System.__ComObject".... Now the question: Using what operation could I convert m_object from "System.__ComObject" to my original "UserControl1" type???!!!... And if you tell me that this is impossible -- your hyped .NET Framework sucks!!!...LOL Please, don't refference Marshal::CreateWrapperOfType -- cause id doesn't work... Also, maybe you can give me an example on how I could enumerate WinForm controls on HTML page, from inside one of them and get native .NET classes for each of them -- maybe there is some method -- don't refference "Container" or "Parent" control properties, because they are both nulls (probably because IE is not managed container)... Anyway, any answer maybe of help... :)

    S 1 Reply Last reply
    0
    • I igor1960

      OK, I have basic and probably simple question for you guys... Here is the situation: Assuming: 1. I have WinForm Control ("UserControl1") sitting on HTML page, let's assume his name on HTML layout is "ctrl"; 2. I have property of that control named "Object" that has set method; 3. My HTML script does the following: ctrl.Object = ctrl I'm setting Object property back to the value of "this" on the site of the control. So, basically, i understand that .NET class through RCW get's converted to IDispatch and then this IDispatch (probably with new CCW) get's passed back to the control. Now, it's not surprising that after that trip I'm getting public object Object { set { m_object = value; < } at <> m_object of type "System.__ComObject".... Now the question: Using what operation could I convert m_object from "System.__ComObject" to my original "UserControl1" type???!!!... And if you tell me that this is impossible -- your hyped .NET Framework sucks!!!...LOL Please, don't refference Marshal::CreateWrapperOfType -- cause id doesn't work... Also, maybe you can give me an example on how I could enumerate WinForm controls on HTML page, from inside one of them and get native .NET classes for each of them -- maybe there is some method -- don't refference "Container" or "Parent" control properties, because they are both nulls (probably because IE is not managed container)... Anyway, any answer maybe of help... :)

      S Offline
      S Offline
      Shaun Wilde
      wrote on last edited by
      #2

      lets get this straight are you trying to manipulate a COM object that is hosted in the client browser from the server side code? if so - you can't (not directly but there is nothing stopping you adding javascript to manipulate the object). if not - then you'll have to make your clarify your question. maybe by source code extracts

      Technically speaking the dictionary would define Visual Basic users as programmers.
      But here again, a very generalized, liberal definition is being employed and it's wrong
      - just plain wrong - Tom Archer 5/12/02

      I 1 Reply Last reply
      0
      • S Shaun Wilde

        lets get this straight are you trying to manipulate a COM object that is hosted in the client browser from the server side code? if so - you can't (not directly but there is nothing stopping you adding javascript to manipulate the object). if not - then you'll have to make your clarify your question. maybe by source code extracts

        Technically speaking the dictionary would define Visual Basic users as programmers.
        But here again, a very generalized, liberal definition is being employed and it's wrong
        - just plain wrong - Tom Archer 5/12/02

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

        Server is not involved at all.. Simple, Container hosts WebBrowser -- now WebBrowser hosts .NET control -- container queries that WebBrowser for HTML content and get's IDispatch of that control from IHtmlElement... Having that IDispatch now Container without any WebBrowser or HTML involvement can call methods on that .NET object... Right???... If so, reverse should be true -- meaning that .NET object getting IDispatch of some other components should be capable of recognizing .NET controls having that IDispatch -- Right?... So, that was my original question... BTW: I know an answer... Instead of using just ctr --> you must just use "ctrl.object"... So, script line will look like this: ctrl.Object = ctrl.object --- hehehehe... UGLY!!!... But seriously: All those .NET Gurus, are just GURUs in there own world!!!... Yesterday I had pretty good dinner and at night when I was in a deep sleep, suddenly I waked up with a terrible pain in my stomach!!!... Did you ever have this???... So, while running to the bathroom and in there I suddenly realized -- I didn't have any "delegate" for that pain -- and I didn't created any "EventHandler" for it -- not to say that I was not planning to call the base class implementation (interesting, what would it be???LOL)... It just happened!!!... Enough joking!!!... So, my point is: You have a pointer which was Marshalled and UnMrashalled, and/or Split and Restored, and/or Divided/Multiplied.... Good system should be able to discover and restore it's Native Type... What is interesting --> that Marshalled IDispact supports IManagedObject even after RCW<->CCW... So, somebody was realy LAZY!!!... OK???!!!... Regards to ALL MSFT GURUS!!!...

        S 1 Reply Last reply
        0
        • I igor1960

          Server is not involved at all.. Simple, Container hosts WebBrowser -- now WebBrowser hosts .NET control -- container queries that WebBrowser for HTML content and get's IDispatch of that control from IHtmlElement... Having that IDispatch now Container without any WebBrowser or HTML involvement can call methods on that .NET object... Right???... If so, reverse should be true -- meaning that .NET object getting IDispatch of some other components should be capable of recognizing .NET controls having that IDispatch -- Right?... So, that was my original question... BTW: I know an answer... Instead of using just ctr --> you must just use "ctrl.object"... So, script line will look like this: ctrl.Object = ctrl.object --- hehehehe... UGLY!!!... But seriously: All those .NET Gurus, are just GURUs in there own world!!!... Yesterday I had pretty good dinner and at night when I was in a deep sleep, suddenly I waked up with a terrible pain in my stomach!!!... Did you ever have this???... So, while running to the bathroom and in there I suddenly realized -- I didn't have any "delegate" for that pain -- and I didn't created any "EventHandler" for it -- not to say that I was not planning to call the base class implementation (interesting, what would it be???LOL)... It just happened!!!... Enough joking!!!... So, my point is: You have a pointer which was Marshalled and UnMrashalled, and/or Split and Restored, and/or Divided/Multiplied.... Good system should be able to discover and restore it's Native Type... What is interesting --> that Marshalled IDispact supports IManagedObject even after RCW<->CCW... So, somebody was realy LAZY!!!... OK???!!!... Regards to ALL MSFT GURUS!!!...

          S Offline
          S Offline
          Shaun Wilde
          wrote on last edited by
          #4

          ah I see what you are trying to do now - does the object host the IDispatch interface? best way would be to see if you can manipulate it via javascript on any exposed methods / properties. Now this is really a COM question not a .NET one - is it possible to cast the interface you get from the query of IHtmlElement castable (bad english I know) into a .NET object - Sorry but there is no guarantee of that as there is no guaranteee in C that an interface can be cast into the supporting object (proxies, tear off interfaces etc and the like) Have you come across the samples that shows how to host a .NET control in a webbrowser? see the authpring custom controls at http://samples.gotdotnet.com/quickstart/aspplus/[^]. I can't remember if any of these uses javascript to manipulate the contents I know this doesn't answer your question but it leads us on a road to find an answer.

          Technically speaking the dictionary would define Visual Basic users as programmers.
          But here again, a very generalized, liberal definition is being employed and it's wrong
          - just plain wrong - Tom Archer 5/12/02

          I 1 Reply Last reply
          0
          • S Shaun Wilde

            ah I see what you are trying to do now - does the object host the IDispatch interface? best way would be to see if you can manipulate it via javascript on any exposed methods / properties. Now this is really a COM question not a .NET one - is it possible to cast the interface you get from the query of IHtmlElement castable (bad english I know) into a .NET object - Sorry but there is no guarantee of that as there is no guaranteee in C that an interface can be cast into the supporting object (proxies, tear off interfaces etc and the like) Have you come across the samples that shows how to host a .NET control in a webbrowser? see the authpring custom controls at http://samples.gotdotnet.com/quickstart/aspplus/[^]. I can't remember if any of these uses javascript to manipulate the contents I know this doesn't answer your question but it leads us on a road to find an answer.

            Technically speaking the dictionary would define Visual Basic users as programmers.
            But here again, a very generalized, liberal definition is being employed and it's wrong
            - just plain wrong - Tom Archer 5/12/02

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

            "does the object host the IDispatch interface?" Man, you are probably one of those who got into the crowd of MSFT beleivers that CLR has nothing to do with COM!!!... Sure -- each object and type in CLR hosts IDispatch -- it's just hidden by implementation, but could be exposed at anytime... From what you are writing I understand you are "language" guy -- casting or not casting -- that something what language allows you to do and not really how it's implemented and if implementation allows you to do that, even if language does not -- then there must be some "trick" to be performed... As to my original question -- forget it -- I have found an aswer... About sample -- listen: I'm not reading samples -- I'm usually writing them -- just very few I'm showing to the crowd... My point was: .NET is great and no question server site programming could be speed up and improved; as to the client -- I'm not so sure... Also: I'm really pissed of by so many young ".NET GURUS" who invented CLR and who are so proud of themselves and etc... They are claiming that this is the best environment and etc, and so on.... While in reality: no questions they performed nice job in Object Data definition and implementation of endless number of namespaces and componentrs, while I would say very poor one and almost nothing in functional logic... Just few examples: 1. During 11+ years of COM, standard property browser is not part of OS, however only after 2 years of .NET it is ==> confirms that they did a good job on implementation front, but very poor on COM -- Right???; 2. About poor functional logic: my previous message about stomach problem at night was not an accident -- those hyped "Delegates" -- this is just pure wrong -- Client Doesn't have to subscrive for an event at least on Programming level -- Even if he doesn't -- he still should be notified(1) -- and second -- Ideal Event implementation shouldn't require me as a programmer to write even 1 line of extra code, and of course shouldn't require me to "call base class, or things will not work"... As well as I shouldn't check for delegates to be not null -- and etc., etc., etc.... I'm not proposing any implementation here -- I'm just pointing the fact that CLR implementation is not the best... 3. Exposing WinForm Controls as an ActiveX Controls was dropped -- why???... Somebody was just LAZY -- you have reflection, so you can generate TypeLibrary on the fly -- they are saying that Each Event has different interface, therefore one [default, source] can't be generated -- wro

            A S A 3 Replies Last reply
            0
            • I igor1960

              "does the object host the IDispatch interface?" Man, you are probably one of those who got into the crowd of MSFT beleivers that CLR has nothing to do with COM!!!... Sure -- each object and type in CLR hosts IDispatch -- it's just hidden by implementation, but could be exposed at anytime... From what you are writing I understand you are "language" guy -- casting or not casting -- that something what language allows you to do and not really how it's implemented and if implementation allows you to do that, even if language does not -- then there must be some "trick" to be performed... As to my original question -- forget it -- I have found an aswer... About sample -- listen: I'm not reading samples -- I'm usually writing them -- just very few I'm showing to the crowd... My point was: .NET is great and no question server site programming could be speed up and improved; as to the client -- I'm not so sure... Also: I'm really pissed of by so many young ".NET GURUS" who invented CLR and who are so proud of themselves and etc... They are claiming that this is the best environment and etc, and so on.... While in reality: no questions they performed nice job in Object Data definition and implementation of endless number of namespaces and componentrs, while I would say very poor one and almost nothing in functional logic... Just few examples: 1. During 11+ years of COM, standard property browser is not part of OS, however only after 2 years of .NET it is ==> confirms that they did a good job on implementation front, but very poor on COM -- Right???; 2. About poor functional logic: my previous message about stomach problem at night was not an accident -- those hyped "Delegates" -- this is just pure wrong -- Client Doesn't have to subscrive for an event at least on Programming level -- Even if he doesn't -- he still should be notified(1) -- and second -- Ideal Event implementation shouldn't require me as a programmer to write even 1 line of extra code, and of course shouldn't require me to "call base class, or things will not work"... As well as I shouldn't check for delegates to be not null -- and etc., etc., etc.... I'm not proposing any implementation here -- I'm just pointing the fact that CLR implementation is not the best... 3. Exposing WinForm Controls as an ActiveX Controls was dropped -- why???... Somebody was just LAZY -- you have reflection, so you can generate TypeLibrary on the fly -- they are saying that Each Event has different interface, therefore one [default, source] can't be generated -- wro

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

              fine so - you found an answer - mind sharing it with us are you one of those take take take and never give back people

              I 1 Reply Last reply
              0
              • A Anonymous

                fine so - you found an answer - mind sharing it with us are you one of those take take take and never give back people

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

                Anonymous, are you able to read????... I thought I gave an answer: >> Assuming: 1. I have WinForm Control ("UserControl1") sitting on HTML page, let's assume his name on HTML layout is "ctrl"; 2. I have property of that control named "Object" that has set method; 3. My HTML script does the following: ctrl.Object = ctrl <<<<====!!!! I'm setting Object property back to the value of "this" on the site of the control...... << In my next message I gave an answer: >> You should use: ctrl.Object = ctrl.object <=== Check "ctrl.object" here, instead of just "ctrl"... Now: "ctrl" is IHtmlObject wrapper created by IE around real .NET IDispatch, while: "ctrl.object" is IDispatch of an Object itsel (doesn't have to be .NET BTW)... As to me never giving back -- maybe... But I never take either...:););P

                1 Reply Last reply
                0
                • I igor1960

                  "does the object host the IDispatch interface?" Man, you are probably one of those who got into the crowd of MSFT beleivers that CLR has nothing to do with COM!!!... Sure -- each object and type in CLR hosts IDispatch -- it's just hidden by implementation, but could be exposed at anytime... From what you are writing I understand you are "language" guy -- casting or not casting -- that something what language allows you to do and not really how it's implemented and if implementation allows you to do that, even if language does not -- then there must be some "trick" to be performed... As to my original question -- forget it -- I have found an aswer... About sample -- listen: I'm not reading samples -- I'm usually writing them -- just very few I'm showing to the crowd... My point was: .NET is great and no question server site programming could be speed up and improved; as to the client -- I'm not so sure... Also: I'm really pissed of by so many young ".NET GURUS" who invented CLR and who are so proud of themselves and etc... They are claiming that this is the best environment and etc, and so on.... While in reality: no questions they performed nice job in Object Data definition and implementation of endless number of namespaces and componentrs, while I would say very poor one and almost nothing in functional logic... Just few examples: 1. During 11+ years of COM, standard property browser is not part of OS, however only after 2 years of .NET it is ==> confirms that they did a good job on implementation front, but very poor on COM -- Right???; 2. About poor functional logic: my previous message about stomach problem at night was not an accident -- those hyped "Delegates" -- this is just pure wrong -- Client Doesn't have to subscrive for an event at least on Programming level -- Even if he doesn't -- he still should be notified(1) -- and second -- Ideal Event implementation shouldn't require me as a programmer to write even 1 line of extra code, and of course shouldn't require me to "call base class, or things will not work"... As well as I shouldn't check for delegates to be not null -- and etc., etc., etc.... I'm not proposing any implementation here -- I'm just pointing the fact that CLR implementation is not the best... 3. Exposing WinForm Controls as an ActiveX Controls was dropped -- why???... Somebody was just LAZY -- you have reflection, so you can generate TypeLibrary on the fly -- they are saying that Each Event has different interface, therefore one [default, source] can't be generated -- wro

                  S Offline
                  S Offline
                  Shaun Wilde
                  wrote on last edited by
                  #8

                  Okay I see where you coming from but... Originally you seemed to be accessing your code from .NET and now you seem to be to just doing it via javascript. Is this the case are you still trying to turn your IHTMLElement into the original object or are you just sticking with the exposed IDispatch

                  Technically speaking the dictionary would define Visual Basic users as programmers.
                  But here again, a very generalized, liberal definition is being employed and it's wrong
                  - just plain wrong - Tom Archer 5/12/02

                  1 Reply Last reply
                  0
                  • I igor1960

                    "does the object host the IDispatch interface?" Man, you are probably one of those who got into the crowd of MSFT beleivers that CLR has nothing to do with COM!!!... Sure -- each object and type in CLR hosts IDispatch -- it's just hidden by implementation, but could be exposed at anytime... From what you are writing I understand you are "language" guy -- casting or not casting -- that something what language allows you to do and not really how it's implemented and if implementation allows you to do that, even if language does not -- then there must be some "trick" to be performed... As to my original question -- forget it -- I have found an aswer... About sample -- listen: I'm not reading samples -- I'm usually writing them -- just very few I'm showing to the crowd... My point was: .NET is great and no question server site programming could be speed up and improved; as to the client -- I'm not so sure... Also: I'm really pissed of by so many young ".NET GURUS" who invented CLR and who are so proud of themselves and etc... They are claiming that this is the best environment and etc, and so on.... While in reality: no questions they performed nice job in Object Data definition and implementation of endless number of namespaces and componentrs, while I would say very poor one and almost nothing in functional logic... Just few examples: 1. During 11+ years of COM, standard property browser is not part of OS, however only after 2 years of .NET it is ==> confirms that they did a good job on implementation front, but very poor on COM -- Right???; 2. About poor functional logic: my previous message about stomach problem at night was not an accident -- those hyped "Delegates" -- this is just pure wrong -- Client Doesn't have to subscrive for an event at least on Programming level -- Even if he doesn't -- he still should be notified(1) -- and second -- Ideal Event implementation shouldn't require me as a programmer to write even 1 line of extra code, and of course shouldn't require me to "call base class, or things will not work"... As well as I shouldn't check for delegates to be not null -- and etc., etc., etc.... I'm not proposing any implementation here -- I'm just pointing the fact that CLR implementation is not the best... 3. Exposing WinForm Controls as an ActiveX Controls was dropped -- why???... Somebody was just LAZY -- you have reflection, so you can generate TypeLibrary on the fly -- they are saying that Each Event has different interface, therefore one [default, source] can't be generated -- wro

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

                    igor1960 wrote: The more mess MSFT creates the more job for me...hehehehe... Ok, you solved your own problem before the gurus. Sounds like you are more interested in showing others how smart you really are. ;) Don't get me wrong, we need more people like you. If you post your code, ideas, observations, and criticism (of microsoft) as articles, it will be more interesting.

                    I 1 Reply Last reply
                    0
                    • A Anonymous101

                      igor1960 wrote: The more mess MSFT creates the more job for me...hehehehe... Ok, you solved your own problem before the gurus. Sounds like you are more interested in showing others how smart you really are. ;) Don't get me wrong, we need more people like you. If you post your code, ideas, observations, and criticism (of microsoft) as articles, it will be more interesting.

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

                      "Don't get me wrong, we need more people like you"... And who the heck are YOU???!!! Why do I need to criticise MSFT???!!! It's doing it's best providing me an my family with "bread and butter"!!!... What I'm criticising -- middle and top level management of other companies, that are very fast in catching next hype in order to preserve there position in hierarchy -- those guys are really "empty" and the only reason for there existance is mess they are creating as well as the only ability to play golf and drink!!!... As to technical issues -- .NET is great, except because it is so, it's pretty simple to implement simple tasks, while difficult to perform and/or have knowledge on how to implemet difficult/not ordinary ones... That's it...

                      A 1 Reply Last reply
                      0
                      • I igor1960

                        "Don't get me wrong, we need more people like you"... And who the heck are YOU???!!! Why do I need to criticise MSFT???!!! It's doing it's best providing me an my family with "bread and butter"!!!... What I'm criticising -- middle and top level management of other companies, that are very fast in catching next hype in order to preserve there position in hierarchy -- those guys are really "empty" and the only reason for there existance is mess they are creating as well as the only ability to play golf and drink!!!... As to technical issues -- .NET is great, except because it is so, it's pretty simple to implement simple tasks, while difficult to perform and/or have knowledge on how to implemet difficult/not ordinary ones... That's it...

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

                        "And who the heck are YOU???!!!" I am Anonymous101. If you think the name doesn't give enough information, I could change it to something like Anonymous1960. ;-) "Why do I need to criticise MSFT???!!! It's doing it's best providing me an my family with "bread and butter"!!!... What I'm criticising -- middle and top level management of other companies, that are very fast in catching next hype in order to preserve there position in hierarchy -- those guys are really "empty" and the only reason for there existance is mess they are creating as well as the only ability to play golf and drink!!!..." Looking at the number of exclamation marks, it seems that you have more anger in your chest than a suicide bomber. Why? Let me guess, you think .NET has made programming too easy and therefore takes some of the privileges away to smart guys like you, right? Either your confidence or your skill is overrated. ;-)

                        I 1 Reply Last reply
                        0
                        • A Anonymous101

                          "And who the heck are YOU???!!!" I am Anonymous101. If you think the name doesn't give enough information, I could change it to something like Anonymous1960. ;-) "Why do I need to criticise MSFT???!!! It's doing it's best providing me an my family with "bread and butter"!!!... What I'm criticising -- middle and top level management of other companies, that are very fast in catching next hype in order to preserve there position in hierarchy -- those guys are really "empty" and the only reason for there existance is mess they are creating as well as the only ability to play golf and drink!!!..." Looking at the number of exclamation marks, it seems that you have more anger in your chest than a suicide bomber. Why? Let me guess, you think .NET has made programming too easy and therefore takes some of the privileges away to smart guys like you, right? Either your confidence or your skill is overrated. ;-)

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

                          Get a life...

                          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