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. C#
  4. Force CLR Version

Force CLR Version

Scheduled Pinned Locked Moved C#
dotnetannouncement
16 Posts 5 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.
  • 0 Offline
    0 Offline
    0905v49
    wrote on last edited by
    #1

    My dll is built in 2.0 Framework but still its using runtime 4.0 while consuming in the application. I need to force my dll to use CLR Runtime version 2.0 instead of 4.0. Is there any way to do it.

    L E A D 4 Replies Last reply
    0
    • 0 0905v49

      My dll is built in 2.0 Framework but still its using runtime 4.0 while consuming in the application. I need to force my dll to use CLR Runtime version 2.0 instead of 4.0. Is there any way to do it.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Did you reference any other assemblies from the 4.0 framework? What framework is the solution targetting? (See project properties page)

      Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] They hate us for our freedom![^]

      0 1 Reply Last reply
      0
      • L Lost User

        Did you reference any other assemblies from the 4.0 framework? What framework is the solution targetting? (See project properties page)

        Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] They hate us for our freedom![^]

        0 Offline
        0 Offline
        0905v49
        wrote on last edited by
        #3

        No am not using any assemblies from 4.0 framework and it is targetting to 2.0 framework.

        L 1 Reply Last reply
        0
        • 0 0905v49

          My dll is built in 2.0 Framework but still its using runtime 4.0 while consuming in the application. I need to force my dll to use CLR Runtime version 2.0 instead of 4.0. Is there any way to do it.

          E Offline
          E Offline
          Ennis Ray Lynch Jr
          wrote on last edited by
          #4

          Try running it on a machine with no net 4.0 installed.

          Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. "And they, since they Were not the one dead, turned to their affairs" -- Robert Frost "All users always want Excel" --Ennis Lynch

          0 1 Reply Last reply
          0
          • E Ennis Ray Lynch Jr

            Try running it on a machine with no net 4.0 installed.

            Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. "And they, since they Were not the one dead, turned to their affairs" -- Robert Frost "All users always want Excel" --Ennis Lynch

            0 Offline
            0 Offline
            0905v49
            wrote on last edited by
            #5

            Thank you for the reply. I have tried with 3.5 ramework still same issue. The actual problem is I am using axcepta 2.0 version dll in .net 2.0 version which is finally using by java application. This works fine with any .net app. But When it goes to java the .net 2.0 dll is running with 4.0CLR there i am getting the Mixed mode assembly reference issue.

            1 Reply Last reply
            0
            • 0 0905v49

              My dll is built in 2.0 Framework but still its using runtime 4.0 while consuming in the application. I need to force my dll to use CLR Runtime version 2.0 instead of 4.0. Is there any way to do it.

              A Offline
              A Offline
              Alan N
              wrote on last edited by
              #6

              Have you tried adding a supportedRunTime element to the application's configuration file? See http://msdn.microsoft.com/en-us/library/w4atty68(v=vs.80).aspx[^] I can't tell from the documentation if this would force a particular version of the CLR to load, but it would be worth doing an experiment to find out. Alan

              0 1 Reply Last reply
              0
              • 0 0905v49

                My dll is built in 2.0 Framework but still its using runtime 4.0 while consuming in the application. I need to force my dll to use CLR Runtime version 2.0 instead of 4.0. Is there any way to do it.

                D Offline
                D Offline
                Dave Kreskowiak
                wrote on last edited by
                #7

                You cannot force a .DLL to use a specific CLR version. The code will run under whatever the CLR version the .EXE is using. .DLL's are loaded into the process the same as any other code in the .EXE. If you want to change which version of the CLR the code uses, you have to specify that in the application manifest file. How to: Configure an Application to Target a .NET Framework Version[^]

                A guide to posting questions on CodeProject[^]
                Dave Kreskowiak

                0 1 Reply Last reply
                0
                • D Dave Kreskowiak

                  You cannot force a .DLL to use a specific CLR version. The code will run under whatever the CLR version the .EXE is using. .DLL's are loaded into the process the same as any other code in the .EXE. If you want to change which version of the CLR the code uses, you have to specify that in the application manifest file. How to: Configure an Application to Target a .NET Framework Version[^]

                  A guide to posting questions on CodeProject[^]
                  Dave Kreskowiak

                  0 Offline
                  0 Offline
                  0905v49
                  wrote on last edited by
                  #8

                  Do you mean app.config file? Even though I specify in app.config but my deliverable is only dll so it dnt work out for me.

                  D 1 Reply Last reply
                  0
                  • A Alan N

                    Have you tried adding a supportedRunTime element to the application's configuration file? See http://msdn.microsoft.com/en-us/library/w4atty68(v=vs.80).aspx[^] I can't tell from the documentation if this would force a particular version of the CLR to load, but it would be worth doing an experiment to find out. Alan

                    0 Offline
                    0 Offline
                    0905v49
                    wrote on last edited by
                    #9

                    No it will not as my deliverable is only dll file not app.config file.

                    1 Reply Last reply
                    0
                    • 0 0905v49

                      No am not using any assemblies from 4.0 framework and it is targetting to 2.0 framework.

                      L Offline
                      L Offline
                      Lost User
                      wrote on last edited by
                      #10

                      0905v49 wrote:

                      No am not using any assemblies from 4.0 framework and it is targetting to 2.0 framework.

                      Then your assembly will work on .NET 2.0 (and up!); which runtime it uses depends on the app that consumes the assembly, and all it's references. I do not see a problem with it running on CLR 4.0. Do you?

                      Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] They hate us for our freedom![^]

                      1 Reply Last reply
                      0
                      • 0 0905v49

                        Do you mean app.config file? Even though I specify in app.config but my deliverable is only dll so it dnt work out for me.

                        D Offline
                        D Offline
                        Dave Kreskowiak
                        wrote on last edited by
                        #11

                        Sorry, yes, app.config. config files only work with .EXE's. You cannot make an app.config for a .DLL file. The .DLL is loaded as part of the .EXE as if it was in the same file as the .EXE. That's why config's only work with .EXE's and not .DLL's. If you want your .DLL to run with a certain CLR version, the .EXE that's loading it ALSO has to run with that CLR version.

                        A guide to posting questions on CodeProject[^]
                        Dave Kreskowiak

                        0 1 Reply Last reply
                        0
                        • D Dave Kreskowiak

                          Sorry, yes, app.config. config files only work with .EXE's. You cannot make an app.config for a .DLL file. The .DLL is loaded as part of the .EXE as if it was in the same file as the .EXE. That's why config's only work with .EXE's and not .DLL's. If you want your .DLL to run with a certain CLR version, the .EXE that's loading it ALSO has to run with that CLR version.

                          A guide to posting questions on CodeProject[^]
                          Dave Kreskowiak

                          0 Offline
                          0 Offline
                          0905v49
                          wrote on last edited by
                          #12

                          Hi Dave, I have to creat only class library which is using in JNI(java). So I have specify target version through my class library code. Is there any way to do this.

                          D 1 Reply Last reply
                          0
                          • 0 0905v49

                            Hi Dave, I have to creat only class library which is using in JNI(java). So I have specify target version through my class library code. Is there any way to do this.

                            D Offline
                            D Offline
                            Dave Kreskowiak
                            wrote on last edited by
                            #13

                            Again, no. The only way to do that is to specify it in the app.config of the HOST .EXE that is loading your .DLL. Why can't your .DLL run under the .NET 4.0 CLR??

                            A guide to posting questions on CodeProject[^]
                            Dave Kreskowiak

                            0 2 Replies Last reply
                            0
                            • D Dave Kreskowiak

                              Again, no. The only way to do that is to specify it in the app.config of the HOST .EXE that is loading your .DLL. Why can't your .DLL run under the .NET 4.0 CLR??

                              A guide to posting questions on CodeProject[^]
                              Dave Kreskowiak

                              0 Offline
                              0 Offline
                              0905v49
                              wrote on last edited by
                              #14

                              I am using Microsoft.Dynamics.BusinessConnectorNet with this which is compiled in 2.0 version. My dll works fine in .net environment where i can set supportedruntime in appconfig. But when dll goes to JNI it is running under the latest .net framework i.e 4.0 installed in that system and giving the mixed mode assembly exception .

                              D 1 Reply Last reply
                              0
                              • D Dave Kreskowiak

                                Again, no. The only way to do that is to specify it in the app.config of the HOST .EXE that is loading your .DLL. Why can't your .DLL run under the .NET 4.0 CLR??

                                A guide to posting questions on CodeProject[^]
                                Dave Kreskowiak

                                0 Offline
                                0 Offline
                                0905v49
                                wrote on last edited by
                                #15

                                I am using Microsoft.Dynamics.BusinessConnectorNet with this which is compiled in 2.0 version.

                                My dll works fine in .net environment where i can set supportedruntime in appconfig.
                                But when dll goes to JNI it is running under the latest .net framework i.e 4.0 installed in that system and giving the mixed mode assembly exception .

                                1 Reply Last reply
                                0
                                • 0 0905v49

                                  I am using Microsoft.Dynamics.BusinessConnectorNet with this which is compiled in 2.0 version. My dll works fine in .net environment where i can set supportedruntime in appconfig. But when dll goes to JNI it is running under the latest .net framework i.e 4.0 installed in that system and giving the mixed mode assembly exception .

                                  D Offline
                                  D Offline
                                  Dave Kreskowiak
                                  wrote on last edited by
                                  #16

                                  Well, we've told you the only way to do it, and you've even said that you've tried it and it works ("supportedruntime in appconfig"). The only other option you have to to get an updated Dynamics library and compile a second version of your .DLL that works with the .NET 4.0 CLR.

                                  A guide to posting questions on CodeProject[^]
                                  Dave Kreskowiak

                                  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