MongoDB client throws a FileNotFoundException in mscorlib












15















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





























    15















    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



























      15












      15








      15


      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









      HealdGuildHealdGuild

      7615




      7615
























          7 Answers
          7






          active

          oldest

          votes


















          13














          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



















          7














          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































            7














            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































              3














              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































                1














                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































                  0














                  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































                    0














                    It looks crazy, but.
                    I got this problem in Windows Server 2012 R2.



                    Only installation latest updates did help.
                    It was "2018-12 Security and Quality Rollup for .NET for Windows..." (KB4471989).






                    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',
                      autoActivateHeartbeat: false,
                      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

























                      7 Answers
                      7






                      active

                      oldest

                      votes








                      7 Answers
                      7






                      active

                      oldest

                      votes









                      active

                      oldest

                      votes






                      active

                      oldest

                      votes









                      13














                      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
















                      13














                      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














                      13












                      13








                      13







                      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









                      user3096476user3096476

                      21215




                      21215













                      • 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













                      7














                      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




























                        7














                        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


























                          7












                          7








                          7







                          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









                          TimTim

                          32627




                          32627























                              7














                              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




























                                7














                                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


























                                  7












                                  7








                                  7







                                  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 '18 at 19:02









                                  Galo CegoGalo Cego

                                  7112




                                  7112























                                      3














                                      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




























                                        3














                                        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


























                                          3












                                          3








                                          3







                                          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









                                          KunalKunal

                                          343




                                          343























                                              1














                                              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




























                                                1














                                                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


























                                                  1












                                                  1








                                                  1







                                                  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 '18 at 14:03









                                                  EarleeEarlee

                                                  73214




                                                  73214























                                                      0














                                                      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




























                                                        0














                                                        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


























                                                          0












                                                          0








                                                          0







                                                          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 '18 at 21:37









                                                          ibiriteibirite

                                                          43035




                                                          43035























                                                              0














                                                              It looks crazy, but.
                                                              I got this problem in Windows Server 2012 R2.



                                                              Only installation latest updates did help.
                                                              It was "2018-12 Security and Quality Rollup for .NET for Windows..." (KB4471989).






                                                              share|improve this answer




























                                                                0














                                                                It looks crazy, but.
                                                                I got this problem in Windows Server 2012 R2.



                                                                Only installation latest updates did help.
                                                                It was "2018-12 Security and Quality Rollup for .NET for Windows..." (KB4471989).






                                                                share|improve this answer


























                                                                  0












                                                                  0








                                                                  0







                                                                  It looks crazy, but.
                                                                  I got this problem in Windows Server 2012 R2.



                                                                  Only installation latest updates did help.
                                                                  It was "2018-12 Security and Quality Rollup for .NET for Windows..." (KB4471989).






                                                                  share|improve this answer













                                                                  It looks crazy, but.
                                                                  I got this problem in Windows Server 2012 R2.



                                                                  Only installation latest updates did help.
                                                                  It was "2018-12 Security and Quality Rollup for .NET for Windows..." (KB4471989).







                                                                  share|improve this answer












                                                                  share|improve this answer



                                                                  share|improve this answer










                                                                  answered Dec 20 '18 at 13:33









                                                                  Vyacheslav SkripinVyacheslav Skripin

                                                                  1




                                                                  1






























                                                                      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.




                                                                      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

                                                                      Guess what letter conforming each word

                                                                      Port of Spain

                                                                      Run scheduled task as local user group (not BUILTIN)