MongoDB client throws a FileNotFoundException in mscorlib











up vote
10
down vote

favorite
2












I'm using Visual Studio .NET 4.6 and Robomongo has no problem connecting to my database



My imports for MongoDB



using MongoDB.Driver;
using MongoDB.Driver.Builders;
using MongoDB.Bson;


The code that's executing:



MongoClient client = new MongoClient("mongodb://localhost");
MongoServer server = client.GetServer();
MongoDatabase mongoDatabase = server.GetDatabase("GameCollection");


The full error message:




An unhandled exception of type 'System.IO.FileNotFoundException'
occurred in mscorlib.dll



Additional information: Could not load file or assembly
'System.Runtime.InteropServices.RuntimeInformation, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its
dependencies. The system cannot find the file specified.











share|improve this question




























    up vote
    10
    down vote

    favorite
    2












    I'm using Visual Studio .NET 4.6 and Robomongo has no problem connecting to my database



    My imports for MongoDB



    using MongoDB.Driver;
    using MongoDB.Driver.Builders;
    using MongoDB.Bson;


    The code that's executing:



    MongoClient client = new MongoClient("mongodb://localhost");
    MongoServer server = client.GetServer();
    MongoDatabase mongoDatabase = server.GetDatabase("GameCollection");


    The full error message:




    An unhandled exception of type 'System.IO.FileNotFoundException'
    occurred in mscorlib.dll



    Additional information: Could not load file or assembly
    'System.Runtime.InteropServices.RuntimeInformation, Version=4.0.0.0,
    Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its
    dependencies. The system cannot find the file specified.











    share|improve this question


























      up vote
      10
      down vote

      favorite
      2









      up vote
      10
      down vote

      favorite
      2






      2





      I'm using Visual Studio .NET 4.6 and Robomongo has no problem connecting to my database



      My imports for MongoDB



      using MongoDB.Driver;
      using MongoDB.Driver.Builders;
      using MongoDB.Bson;


      The code that's executing:



      MongoClient client = new MongoClient("mongodb://localhost");
      MongoServer server = client.GetServer();
      MongoDatabase mongoDatabase = server.GetDatabase("GameCollection");


      The full error message:




      An unhandled exception of type 'System.IO.FileNotFoundException'
      occurred in mscorlib.dll



      Additional information: Could not load file or assembly
      'System.Runtime.InteropServices.RuntimeInformation, Version=4.0.0.0,
      Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its
      dependencies. The system cannot find the file specified.











      share|improve this question















      I'm using Visual Studio .NET 4.6 and Robomongo has no problem connecting to my database



      My imports for MongoDB



      using MongoDB.Driver;
      using MongoDB.Driver.Builders;
      using MongoDB.Bson;


      The code that's executing:



      MongoClient client = new MongoClient("mongodb://localhost");
      MongoServer server = client.GetServer();
      MongoDatabase mongoDatabase = server.GetDatabase("GameCollection");


      The full error message:




      An unhandled exception of type 'System.IO.FileNotFoundException'
      occurred in mscorlib.dll



      Additional information: Could not load file or assembly
      'System.Runtime.InteropServices.RuntimeInformation, Version=4.0.0.0,
      Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its
      dependencies. The system cannot find the file specified.








      c# mongodb database nosql






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Sep 22 '17 at 18:01









      Community

      11




      11










      asked Nov 1 '16 at 20:35









      HealdGuild

      5115




      5115
























          6 Answers
          6






          active

          oldest

          votes

















          up vote
          12
          down vote













          Install the missing package. Using Package-installer, issue following command:
          Install-Package System.Runtime.InteropServices.RuntimeInformation






          share|improve this answer





















          • Need to render the project open to issue the command.
            – Bruce Yo
            Dec 17 '16 at 12:36


















          up vote
          5
          down vote













          In my case I already had System.Runtime.InteropServices.RuntimeInformation installed, yet it kept giving me the same errror. Either complaining that 4.0.0.0 was not found, or if I updated the app.config to 4.3, it complained that 4.3.0.0 was missing.



          However, after uninstalling and reinstalleding several packages it started working, and even though version 4.3 of the System.Runtime.InteropServices.RuntimeInformation was installed, it required the app.config to have 4.0.1.0



          <dependentAssembly>
          <assemblyIdentity name="System.Runtime.InteropServices.RuntimeInformation" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
          </dependentAssembly>


          I have no idea why, but it finally works for me.






          share|improve this answer




























            up vote
            3
            down vote













            After much experimentation, it seems web.config needs the following to work:



            <dependentAssembly>
            <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" />
            </dependentAssembly>
            <dependentAssembly>
            <assemblyIdentity name="System.Runtime.InteropServices.RuntimeInformation" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
            </dependentAssembly>


            Whatever redirects NuGet was putting there were incorrect. This maybe isn't a MongoDB issue per se, perhaps issue with Microsoft Nuget packages/version stamps.






            share|improve this answer




























              up vote
              3
              down vote













              I had the same problem here. The fix is pretty simple: edit the config file and on the node "dependentAssembly" where name attribute is "System.Runtime.InteropServices.RuntimeInformation", just remove the publicKeyToken attribute.



              Good Luck






              share|improve this answer




























                up vote
                0
                down vote













                I had the same problem here. It took a few minutes do find out that my problem was the fact that I have updated the nuget package "System.Runtime.InteropServices.RuntimeInformation", and it seems that MongoDb csharp's driver reference's has SpecificVersion = true.



                Remove all nuget packages and install it again , or just downgrade it to the same version that it's installed as a MongoDb driver dependency.



                Good luck!






                share|improve this answer




























                  up vote
                  0
                  down vote













                  In my case, the package was already installed. However, there was a mismatch of the versions in the web.config file. A reinstall of the package fixed the issue. Open your Package Manager Console and type in,



                  Update-Package System.Runtime.InteropServices.RuntimeInformation -Reinstall





                  share|improve this answer





















                    Your Answer






                    StackExchange.ifUsing("editor", function () {
                    StackExchange.using("externalEditor", function () {
                    StackExchange.using("snippets", function () {
                    StackExchange.snippets.init();
                    });
                    });
                    }, "code-snippets");

                    StackExchange.ready(function() {
                    var channelOptions = {
                    tags: "".split(" "),
                    id: "1"
                    };
                    initTagRenderer("".split(" "), "".split(" "), channelOptions);

                    StackExchange.using("externalEditor", function() {
                    // Have to fire editor after snippets, if snippets enabled
                    if (StackExchange.settings.snippets.snippetsEnabled) {
                    StackExchange.using("snippets", function() {
                    createEditor();
                    });
                    }
                    else {
                    createEditor();
                    }
                    });

                    function createEditor() {
                    StackExchange.prepareEditor({
                    heartbeatType: 'answer',
                    convertImagesToLinks: true,
                    noModals: true,
                    showLowRepImageUploadWarning: true,
                    reputationToPostImages: 10,
                    bindNavPrevention: true,
                    postfix: "",
                    imageUploader: {
                    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                    allowUrls: true
                    },
                    onDemand: true,
                    discardSelector: ".discard-answer"
                    ,immediatelyShowMarkdownHelp:true
                    });


                    }
                    });














                    draft saved

                    draft discarded


















                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f40368208%2fmongodb-client-throws-a-filenotfoundexception-in-mscorlib%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown

























                    6 Answers
                    6






                    active

                    oldest

                    votes








                    6 Answers
                    6






                    active

                    oldest

                    votes









                    active

                    oldest

                    votes






                    active

                    oldest

                    votes








                    up vote
                    12
                    down vote













                    Install the missing package. Using Package-installer, issue following command:
                    Install-Package System.Runtime.InteropServices.RuntimeInformation






                    share|improve this answer





















                    • Need to render the project open to issue the command.
                      – Bruce Yo
                      Dec 17 '16 at 12:36















                    up vote
                    12
                    down vote













                    Install the missing package. Using Package-installer, issue following command:
                    Install-Package System.Runtime.InteropServices.RuntimeInformation






                    share|improve this answer





















                    • Need to render the project open to issue the command.
                      – Bruce Yo
                      Dec 17 '16 at 12:36













                    up vote
                    12
                    down vote










                    up vote
                    12
                    down vote









                    Install the missing package. Using Package-installer, issue following command:
                    Install-Package System.Runtime.InteropServices.RuntimeInformation






                    share|improve this answer












                    Install the missing package. Using Package-installer, issue following command:
                    Install-Package System.Runtime.InteropServices.RuntimeInformation







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Nov 3 '16 at 6:38









                    user3096476

                    20215




                    20215












                    • Need to render the project open to issue the command.
                      – Bruce Yo
                      Dec 17 '16 at 12:36


















                    • Need to render the project open to issue the command.
                      – Bruce Yo
                      Dec 17 '16 at 12:36
















                    Need to render the project open to issue the command.
                    – Bruce Yo
                    Dec 17 '16 at 12:36




                    Need to render the project open to issue the command.
                    – Bruce Yo
                    Dec 17 '16 at 12:36












                    up vote
                    5
                    down vote













                    In my case I already had System.Runtime.InteropServices.RuntimeInformation installed, yet it kept giving me the same errror. Either complaining that 4.0.0.0 was not found, or if I updated the app.config to 4.3, it complained that 4.3.0.0 was missing.



                    However, after uninstalling and reinstalleding several packages it started working, and even though version 4.3 of the System.Runtime.InteropServices.RuntimeInformation was installed, it required the app.config to have 4.0.1.0



                    <dependentAssembly>
                    <assemblyIdentity name="System.Runtime.InteropServices.RuntimeInformation" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
                    <bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
                    </dependentAssembly>


                    I have no idea why, but it finally works for me.






                    share|improve this answer

























                      up vote
                      5
                      down vote













                      In my case I already had System.Runtime.InteropServices.RuntimeInformation installed, yet it kept giving me the same errror. Either complaining that 4.0.0.0 was not found, or if I updated the app.config to 4.3, it complained that 4.3.0.0 was missing.



                      However, after uninstalling and reinstalleding several packages it started working, and even though version 4.3 of the System.Runtime.InteropServices.RuntimeInformation was installed, it required the app.config to have 4.0.1.0



                      <dependentAssembly>
                      <assemblyIdentity name="System.Runtime.InteropServices.RuntimeInformation" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
                      <bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
                      </dependentAssembly>


                      I have no idea why, but it finally works for me.






                      share|improve this answer























                        up vote
                        5
                        down vote










                        up vote
                        5
                        down vote









                        In my case I already had System.Runtime.InteropServices.RuntimeInformation installed, yet it kept giving me the same errror. Either complaining that 4.0.0.0 was not found, or if I updated the app.config to 4.3, it complained that 4.3.0.0 was missing.



                        However, after uninstalling and reinstalleding several packages it started working, and even though version 4.3 of the System.Runtime.InteropServices.RuntimeInformation was installed, it required the app.config to have 4.0.1.0



                        <dependentAssembly>
                        <assemblyIdentity name="System.Runtime.InteropServices.RuntimeInformation" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
                        <bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
                        </dependentAssembly>


                        I have no idea why, but it finally works for me.






                        share|improve this answer












                        In my case I already had System.Runtime.InteropServices.RuntimeInformation installed, yet it kept giving me the same errror. Either complaining that 4.0.0.0 was not found, or if I updated the app.config to 4.3, it complained that 4.3.0.0 was missing.



                        However, after uninstalling and reinstalleding several packages it started working, and even though version 4.3 of the System.Runtime.InteropServices.RuntimeInformation was installed, it required the app.config to have 4.0.1.0



                        <dependentAssembly>
                        <assemblyIdentity name="System.Runtime.InteropServices.RuntimeInformation" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
                        <bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
                        </dependentAssembly>


                        I have no idea why, but it finally works for me.







                        share|improve this answer












                        share|improve this answer



                        share|improve this answer










                        answered Jul 5 '17 at 20:02









                        Tim

                        30727




                        30727






















                            up vote
                            3
                            down vote













                            After much experimentation, it seems web.config needs the following to work:



                            <dependentAssembly>
                            <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
                            <bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" />
                            </dependentAssembly>
                            <dependentAssembly>
                            <assemblyIdentity name="System.Runtime.InteropServices.RuntimeInformation" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
                            <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
                            </dependentAssembly>


                            Whatever redirects NuGet was putting there were incorrect. This maybe isn't a MongoDB issue per se, perhaps issue with Microsoft Nuget packages/version stamps.






                            share|improve this answer

























                              up vote
                              3
                              down vote













                              After much experimentation, it seems web.config needs the following to work:



                              <dependentAssembly>
                              <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
                              <bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" />
                              </dependentAssembly>
                              <dependentAssembly>
                              <assemblyIdentity name="System.Runtime.InteropServices.RuntimeInformation" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
                              <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
                              </dependentAssembly>


                              Whatever redirects NuGet was putting there were incorrect. This maybe isn't a MongoDB issue per se, perhaps issue with Microsoft Nuget packages/version stamps.






                              share|improve this answer























                                up vote
                                3
                                down vote










                                up vote
                                3
                                down vote









                                After much experimentation, it seems web.config needs the following to work:



                                <dependentAssembly>
                                <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
                                <bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" />
                                </dependentAssembly>
                                <dependentAssembly>
                                <assemblyIdentity name="System.Runtime.InteropServices.RuntimeInformation" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
                                <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
                                </dependentAssembly>


                                Whatever redirects NuGet was putting there were incorrect. This maybe isn't a MongoDB issue per se, perhaps issue with Microsoft Nuget packages/version stamps.






                                share|improve this answer












                                After much experimentation, it seems web.config needs the following to work:



                                <dependentAssembly>
                                <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
                                <bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" />
                                </dependentAssembly>
                                <dependentAssembly>
                                <assemblyIdentity name="System.Runtime.InteropServices.RuntimeInformation" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
                                <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
                                </dependentAssembly>


                                Whatever redirects NuGet was putting there were incorrect. This maybe isn't a MongoDB issue per se, perhaps issue with Microsoft Nuget packages/version stamps.







                                share|improve this answer












                                share|improve this answer



                                share|improve this answer










                                answered Nov 15 '17 at 6:58









                                Kunal

                                312




                                312






















                                    up vote
                                    3
                                    down vote













                                    I had the same problem here. The fix is pretty simple: edit the config file and on the node "dependentAssembly" where name attribute is "System.Runtime.InteropServices.RuntimeInformation", just remove the publicKeyToken attribute.



                                    Good Luck






                                    share|improve this answer

























                                      up vote
                                      3
                                      down vote













                                      I had the same problem here. The fix is pretty simple: edit the config file and on the node "dependentAssembly" where name attribute is "System.Runtime.InteropServices.RuntimeInformation", just remove the publicKeyToken attribute.



                                      Good Luck






                                      share|improve this answer























                                        up vote
                                        3
                                        down vote










                                        up vote
                                        3
                                        down vote









                                        I had the same problem here. The fix is pretty simple: edit the config file and on the node "dependentAssembly" where name attribute is "System.Runtime.InteropServices.RuntimeInformation", just remove the publicKeyToken attribute.



                                        Good Luck






                                        share|improve this answer












                                        I had the same problem here. The fix is pretty simple: edit the config file and on the node "dependentAssembly" where name attribute is "System.Runtime.InteropServices.RuntimeInformation", just remove the publicKeyToken attribute.



                                        Good Luck







                                        share|improve this answer












                                        share|improve this answer



                                        share|improve this answer










                                        answered Oct 12 at 19:02









                                        Galo Cego

                                        312




                                        312






















                                            up vote
                                            0
                                            down vote













                                            I had the same problem here. It took a few minutes do find out that my problem was the fact that I have updated the nuget package "System.Runtime.InteropServices.RuntimeInformation", and it seems that MongoDb csharp's driver reference's has SpecificVersion = true.



                                            Remove all nuget packages and install it again , or just downgrade it to the same version that it's installed as a MongoDb driver dependency.



                                            Good luck!






                                            share|improve this answer

























                                              up vote
                                              0
                                              down vote













                                              I had the same problem here. It took a few minutes do find out that my problem was the fact that I have updated the nuget package "System.Runtime.InteropServices.RuntimeInformation", and it seems that MongoDb csharp's driver reference's has SpecificVersion = true.



                                              Remove all nuget packages and install it again , or just downgrade it to the same version that it's installed as a MongoDb driver dependency.



                                              Good luck!






                                              share|improve this answer























                                                up vote
                                                0
                                                down vote










                                                up vote
                                                0
                                                down vote









                                                I had the same problem here. It took a few minutes do find out that my problem was the fact that I have updated the nuget package "System.Runtime.InteropServices.RuntimeInformation", and it seems that MongoDb csharp's driver reference's has SpecificVersion = true.



                                                Remove all nuget packages and install it again , or just downgrade it to the same version that it's installed as a MongoDb driver dependency.



                                                Good luck!






                                                share|improve this answer












                                                I had the same problem here. It took a few minutes do find out that my problem was the fact that I have updated the nuget package "System.Runtime.InteropServices.RuntimeInformation", and it seems that MongoDb csharp's driver reference's has SpecificVersion = true.



                                                Remove all nuget packages and install it again , or just downgrade it to the same version that it's installed as a MongoDb driver dependency.



                                                Good luck!







                                                share|improve this answer












                                                share|improve this answer



                                                share|improve this answer










                                                answered Jan 9 at 21:37









                                                ibirite

                                                31025




                                                31025






















                                                    up vote
                                                    0
                                                    down vote













                                                    In my case, the package was already installed. However, there was a mismatch of the versions in the web.config file. A reinstall of the package fixed the issue. Open your Package Manager Console and type in,



                                                    Update-Package System.Runtime.InteropServices.RuntimeInformation -Reinstall





                                                    share|improve this answer

























                                                      up vote
                                                      0
                                                      down vote













                                                      In my case, the package was already installed. However, there was a mismatch of the versions in the web.config file. A reinstall of the package fixed the issue. Open your Package Manager Console and type in,



                                                      Update-Package System.Runtime.InteropServices.RuntimeInformation -Reinstall





                                                      share|improve this answer























                                                        up vote
                                                        0
                                                        down vote










                                                        up vote
                                                        0
                                                        down vote









                                                        In my case, the package was already installed. However, there was a mismatch of the versions in the web.config file. A reinstall of the package fixed the issue. Open your Package Manager Console and type in,



                                                        Update-Package System.Runtime.InteropServices.RuntimeInformation -Reinstall





                                                        share|improve this answer












                                                        In my case, the package was already installed. However, there was a mismatch of the versions in the web.config file. A reinstall of the package fixed the issue. Open your Package Manager Console and type in,



                                                        Update-Package System.Runtime.InteropServices.RuntimeInformation -Reinstall






                                                        share|improve this answer












                                                        share|improve this answer



                                                        share|improve this answer










                                                        answered Nov 4 at 14:03









                                                        Earlee

                                                        63213




                                                        63213






























                                                            draft saved

                                                            draft discarded




















































                                                            Thanks for contributing an answer to Stack Overflow!


                                                            • Please be sure to answer the question. Provide details and share your research!

                                                            But avoid



                                                            • Asking for help, clarification, or responding to other answers.

                                                            • Making statements based on opinion; back them up with references or personal experience.


                                                            To learn more, see our tips on writing great answers.





                                                            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                                            Please pay close attention to the following guidance:


                                                            • Please be sure to answer the question. Provide details and share your research!

                                                            But avoid



                                                            • Asking for help, clarification, or responding to other answers.

                                                            • Making statements based on opinion; back them up with references or personal experience.


                                                            To learn more, see our tips on writing great answers.




                                                            draft saved


                                                            draft discarded














                                                            StackExchange.ready(
                                                            function () {
                                                            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f40368208%2fmongodb-client-throws-a-filenotfoundexception-in-mscorlib%23new-answer', 'question_page');
                                                            }
                                                            );

                                                            Post as a guest















                                                            Required, but never shown





















































                                                            Required, but never shown














                                                            Required, but never shown












                                                            Required, but never shown







                                                            Required, but never shown

































                                                            Required, but never shown














                                                            Required, but never shown












                                                            Required, but never shown







                                                            Required, but never shown







                                                            Popular posts from this blog

                                                            Lallio

                                                            Unable to find Lightning Node

                                                            Futebolista