Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I got an NullReferenceException #96

Closed
fzhyzamt opened this issue Jun 5, 2019 · 13 comments
Closed

I got an NullReferenceException #96

fzhyzamt opened this issue Jun 5, 2019 · 13 comments
Assignees

Comments

@fzhyzamt
Copy link

fzhyzamt commented Jun 5, 2019

Hello there,
After the authorization was successful, I chose to store the RefreshToken to KeePass, and then selected the db file in OneDrive. I encountered an error when selecting which file to save to the local.

Step (authorized)

  1. Open Keepass
  2. File -> Open -> Open From OneDrive
  3. Click Microsoft Graph
  4. Wait...
  5. Select store Refresh Token to KeePass database
  6. Select One Drive db file
  7. Select local path "D:\KeePass Password Safe 2\db", this path exists, and file name is "main.kdbx"
  8. Error, select continue or quit

When I chose to store the Refresh Token, I tried another option, stored locally, and encountered the same error.

I tried to download the db file from the web page and then chose to store the RefreshToken to KeePass. I encountered a warning: Failed to sync database, can't find path "D:\KeePass Password Safe 2\db\db\main.kdbx", I The path selected should be "D:\KeePass Password Safe 2\db\main.kdbx"

有关调用实时(JIT)调试而不是此对话框的详细信息,
请参见此消息的结尾。

************** 异常文本 **************
System.NullReferenceException: 未将对象引用设置到对象的实例。
   在 KoenZomersKeePassOneDriveSync.Providers.OneDriveProvider.<OpenFromOneDriveCloudProvider>d__19.MoveNext()
--- 引发异常的上一位置中堆栈跟踪的末尾 ---
   在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   在 KoenZomersKeePassOneDriveSync.KeePassDatabase.<OpenDatabaseFromCloudService>d__2.MoveNext()
--- 引发异常的上一位置中堆栈跟踪的末尾 ---
   在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   在 KoenZomersKeePassOneDriveSync.KoenZomersKeePassOneDriveSyncExt.<MenuFileOpenFromOneDriveOnClick>d__9.MoveNext()
--- 引发异常的上一位置中堆栈跟踪的末尾 ---
   在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()


************** 已加载的程序集 **************
mscorlib
    程序集版本:4.0.0.0
    Win32 版本:4.7.3416.0 built by: NET472REL1LAST_B
    基本代码:file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/mscorlib.dll
----------------------------------------
KeePass
    程序集版本:2.42.1.23464
    Win32 版本:2.42.1.0
    基本代码:file:///D:/KeePass%20Password%20Safe%202/KeePass.exe
----------------------------------------
System
    程序集版本:4.0.0.0
    Win32 版本:4.7.3416.0 built by: NET472REL1LAST_B
    基本代码:file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Windows.Forms
    程序集版本:4.0.0.0
    Win32 版本:4.7.3324.0 built by: NET472REL1LAST_C
    基本代码:file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
    程序集版本:4.0.0.0
    Win32 版本:4.7.3190.0 built by: NET472REL1LAST_C
    基本代码:file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Configuration
    程序集版本:4.0.0.0
    Win32 版本:4.7.3324.0 built by: NET472REL1LAST_C
    基本代码:file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Core
    程序集版本:4.0.0.0
    Win32 版本:4.7.3362.0 built by: NET472REL1LAST_C
    基本代码:file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
----------------------------------------
System.Xml
    程序集版本:4.0.0.0
    Win32 版本:4.7.3190.0 built by: NET472REL1LAST_C
    基本代码:file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
System.Windows.Forms.resources
    程序集版本:4.0.0.0
    Win32 版本:4.7.3190.0 built by: NET472REL1LAST_C
    基本代码:file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms.resources/v4.0_4.0.0.0_zh-Hans_b77a5c561934e089/System.Windows.Forms.resources.dll
----------------------------------------
KoenZomersKeePassOneDriveSync
    程序集版本:2.0.6.0
    Win32 版本:2.0.6.0
    基本代码:file:///C:/Users/XXXX/AppData/Local/KeePass/PluginCache/qjRc3mDqplTaKdqcHF0g/KoenZomersKeePassOneDriveSync.dll
----------------------------------------
Newtonsoft.Json
    程序集版本:8.0.0.0
    Win32 版本:8.0.1.19229
    基本代码:file:///C:/Users/XXXX/AppData/Local/KeePass/PluginCache/qjRc3mDqplTaKdqcHF0g/Newtonsoft.Json.DLL
----------------------------------------
System.Numerics
    程序集版本:4.0.0.0
    Win32 版本:4.7.3190.0 built by: NET472REL1LAST_C
    基本代码:file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Numerics/v4.0_4.0.0.0__b77a5c561934e089/System.Numerics.dll
----------------------------------------
System.Runtime.Serialization
    程序集版本:4.0.0.0
    Win32 版本:4.7.3324.0 built by: NET472REL1LAST_C
    基本代码:file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Runtime.Serialization/v4.0_4.0.0.0__b77a5c561934e089/System.Runtime.Serialization.dll
----------------------------------------
System.Xml.Linq
    程序集版本:4.0.0.0
    Win32 版本:4.7.3190.0 built by: NET472REL1LAST_C
    基本代码:file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Xml.Linq/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.Linq.dll
----------------------------------------
System.Data
    程序集版本:4.0.0.0
    Win32 版本:4.7.3260.0 built by: NET472REL1LAST_C
    基本代码:file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_64/System.Data/v4.0_4.0.0.0__b77a5c561934e089/System.Data.dll
----------------------------------------
System.Security
    程序集版本:4.0.0.0
    Win32 版本:4.7.3190.0 built by: NET472REL1LAST_C
    基本代码:file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Security/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Security.dll
----------------------------------------
KeePass.XmlSerializers
    程序集版本:2.42.1.23464
    Win32 版本:2.42.1.23464
    基本代码:file:///D:/KeePass%20Password%20Safe%202/KeePass.XmlSerializers.DLL
----------------------------------------
mscorlib.resources
    程序集版本:4.0.0.0
    Win32 版本:4.7.3190.0 built by: NET472REL1LAST_C
    基本代码:file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/mscorlib.resources/v4.0_4.0.0.0_zh-Hans_b77a5c561934e089/mscorlib.resources.dll
----------------------------------------
KoenZomers.OneDrive.Api
    程序集版本:2.3.0.3
    Win32 版本:2.3.0.3
    基本代码:file:///C:/Users/XXXX/AppData/Local/KeePass/PluginCache/qjRc3mDqplTaKdqcHF0g/KoenZomers.OneDrive.Api.DLL
----------------------------------------
Microsoft.mshtml
    程序集版本:7.0.3300.0
    Win32 版本:7.0.3300.0
    基本代码:file:///C:/WINDOWS/assembly/GAC/Microsoft.mshtml/7.0.3300.0__b03f5f7f11d50a3a/Microsoft.mshtml.dll
----------------------------------------
System.Web
    程序集版本:4.0.0.0
    Win32 版本:4.7.3282.0 built by: NET472REL1LAST_B
    基本代码:file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_64/System.Web/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Web.dll
----------------------------------------
System.Net.Http
    程序集版本:4.0.0.0
    Win32 版本:4.7.3190.0 built by: NET472REL1LAST_C
    基本代码:file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Net.Http/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Net.Http.dll
----------------------------------------
Accessibility
    程序集版本:4.0.0.0
    Win32 版本:4.7.3190.0 built by: NET472REL1LAST_C
    基本代码:file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/Accessibility/v4.0_4.0.0.0__b03f5f7f11d50a3a/Accessibility.dll
----------------------------------------
************** JIT 调试 **************
要启用实时(JIT)调试,
该应用程序或计算机的 .config 文件(machine.config)的 system.windows.forms 节中必须设置
jitDebugging 值。
编译应用程序时还必须启用
调试。
例如:
<configuration>
    <system.windows.forms jitDebugging="true" />
</configuration>
启用 JIT 调试后,任何未经处理的异常
都将被发送到在此计算机上注册的 JIT 调试程序,
而不是由此对话框处理。
@fzhyzamt
Copy link
Author

fzhyzamt commented Jun 5, 2019

I know, I deleted the space in the path and it was successfully synchronized. Everything is fine.

@KoenZomers
Copy link
Owner

Nice that you found it already. It should have thrown a nicer message at least. So what was the issue exactly so I can repro it and ensure it doesn't throw this large exception? The local path wasn't a valid path?

@fzhyzamt
Copy link
Author

fzhyzamt commented Jun 5, 2019

The only change I made was to remove the space in the path.
before: "D:\KeePass Password Safe 2\db"
after: "D:\KeePassPasswordSafe2\db"
I think it's probably a mistake to split spaces when dealing with local paths.

@KoenZomers
Copy link
Owner

Check. And the after path is the one that actually exists on your environment, right?

@fzhyzamt
Copy link
Author

fzhyzamt commented Jun 5, 2019

alway, I just modify folder name

@fzhyzamt
Copy link
Author

fzhyzamt commented Jun 8, 2019

updateStatus(string.Format("Downloading KeePass database {0}", databaseConfig.KeePassDatabase.Name));

I added a record before this line.
like this :

System.IO.File.WriteAllText(@"E:\databaseConfig.txt", JsonConvert.SerializeObject(databaseConfig), Encoding.UTF8);
System.IO.File.WriteAllText(@"E:\KeePassDatabase.txt", JsonConvert.SerializeObject(databaseConfig.KeePassDatabase), Encoding.UTF8);
# databaseConfig.txt
{
  "RefreshToken": "I replace this data",
  "RefreshTokenStorage": 3,
  "OneDriveName": "I replace this data",
  "RemoteDatabasePath": "/drive/root:/pwd/main.kdbx",
  "RemoteFolderId": "I replace this data",
  "RemoteDriveId": "I replace this data",
  "RemoteItemId": "I replace this data",
  "RemoteFileName": "main.kdbx",
  "DoNotSync": false,
  "LocalFileHash": null,
  "ETag": null,
  "LastSyncedAt": null,
  "LastCheckedAt": null,
  "CloudStorageType": 2
}

# KeePassDatabase.txt
null

So databaseConfig.KeePassDatabase is null
I hope I can help you.

@DanielHH87
Copy link

DanielHH87 commented Jun 19, 2019

Good morning,

I have the same issue, but in my case, I don't have a space in my path, I just try to save it as "temp.kdbx" under C:\temp.
What I try to do is:
Open from OneDrive -> Login to my OneDrive for Business -> Store my Refresh Token (I tried both) -> click on the "Shared with me" Tab -> Open the shared Database -> Save it as "temp.kdbx" in C:\temp

Then I get the following Exception:

See the end of this message for details on invoking 
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.NullReferenceException: Object reference not set to an instance of an object.
   at KoenZomersKeePassOneDriveSync.Providers.OneDriveProvider.<OpenFromOneDriveCloudProvider>d__19.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at KoenZomersKeePassOneDriveSync.KeePassDatabase.<OpenDatabaseFromCloudService>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at KoenZomersKeePassOneDriveSync.KoenZomersKeePassOneDriveSyncExt.<MenuFileOpenFromOneDriveOnClick>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()


************** Loaded Assemblies **************
mscorlib
    Assembly Version: 4.0.0.0
    Win32 Version: 4.7.3394.0 built by: NET472REL1LAST_C
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/mscorlib.dll
----------------------------------------
KeePass
    Assembly Version: 2.42.1.23464
    Win32 Version: 2.42.1.0
    CodeBase: file:///C:/Program%20Files%20(x86)/KeePass%20Password%20Safe%202/KeePass.exe
----------------------------------------
System.Windows.Forms
    Assembly Version: 4.0.0.0
    Win32 Version: 4.7.3324.0 built by: NET472REL1LAST_C
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
    Assembly Version: 4.0.0.0
    Win32 Version: 4.7.3362.0 built by: NET472REL1LAST_C
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
    Assembly Version: 4.0.0.0
    Win32 Version: 4.7.3056.0 built by: NET472REL1
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Configuration
    Assembly Version: 4.0.0.0
    Win32 Version: 4.7.3056.0 built by: NET472REL1
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Core
    Assembly Version: 4.0.0.0
    Win32 Version: 4.7.3362.0 built by: NET472REL1LAST_C
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
----------------------------------------
System.Xml
    Assembly Version: 4.0.0.0
    Win32 Version: 4.7.3056.0 built by: NET472REL1
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
KoenZomersKeePassOneDriveSync
    Assembly Version: 2.0.6.0
    Win32 Version: 2.0.6.0
    CodeBase: file:///C:/Users/dhartmann/AppData/Local/KeePass/PluginCache/qjRc3mDqplTaKdqcHF0g/KoenZomersKeePassOneDriveSync.dll
----------------------------------------
Newtonsoft.Json
    Assembly Version: 8.0.0.0
    Win32 Version: 8.0.1.19229
    CodeBase: file:///C:/Users/dhartmann/AppData/Local/KeePass/PluginCache/qjRc3mDqplTaKdqcHF0g/Newtonsoft.Json.DLL
----------------------------------------
System.Numerics
    Assembly Version: 4.0.0.0
    Win32 Version: 4.7.3056.0 built by: NET472REL1
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Numerics/v4.0_4.0.0.0__b77a5c561934e089/System.Numerics.dll
----------------------------------------
System.Runtime.Serialization
    Assembly Version: 4.0.0.0
    Win32 Version: 4.7.3324.0 built by: NET472REL1LAST_C
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Runtime.Serialization/v4.0_4.0.0.0__b77a5c561934e089/System.Runtime.Serialization.dll
----------------------------------------
System.Xml.Linq
    Assembly Version: 4.0.0.0
    Win32 Version: 4.7.3056.0 built by: NET472REL1
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml.Linq/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.Linq.dll
----------------------------------------
System.Data
    Assembly Version: 4.0.0.0
    Win32 Version: 4.7.3260.0 built by: NET472REL1LAST_C
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_64/System.Data/v4.0_4.0.0.0__b77a5c561934e089/System.Data.dll
----------------------------------------
KeePass.XmlSerializers
    Assembly Version: 2.42.1.23464
    Win32 Version: 2.42.1.23464
    CodeBase: file:///C:/Program%20Files%20(x86)/KeePass%20Password%20Safe%202/KeePass.XmlSerializers.DLL
----------------------------------------
KoenZomers.OneDrive.Api
    Assembly Version: 2.3.0.3
    Win32 Version: 2.3.0.3
    CodeBase: file:///C:/Users/dhartmann/AppData/Local/KeePass/PluginCache/qjRc3mDqplTaKdqcHF0g/KoenZomers.OneDrive.Api.DLL
----------------------------------------
Microsoft.mshtml
    Assembly Version: 7.0.3300.0
    Win32 Version: 7.0.3300.0
    CodeBase: file:///C:/Windows/assembly/GAC/Microsoft.mshtml/7.0.3300.0__b03f5f7f11d50a3a/Microsoft.mshtml.dll
----------------------------------------
System.Web
    Assembly Version: 4.0.0.0
    Win32 Version: 4.7.3282.0 built by: NET472REL1LAST_B
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_64/System.Web/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Web.dll
----------------------------------------
System.Net.Http
    Assembly Version: 4.0.0.0
    Win32 Version: 4.7.3056.0 built by: NET472REL1
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Net.Http/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Net.Http.dll
----------------------------------------
OptaneShellExt
    Assembly Version: 1.0.0.0
    Win32 Version: 1.0.0.0
    CodeBase: file:///C:/Program%20Files/Intel/OptaneShellExtensions/OptaneShellExt.dll
----------------------------------------
SharpShell
    Assembly Version: 2.2.0.0
    Win32 Version: 2.2.0.0
    CodeBase: file:///C:/Program%20Files/Intel/OptaneShellExtensions/SharpShell.DLL
----------------------------------------
log4net
    Assembly Version: 1.2.15.0
    Win32 Version: 1.2.15.0
    CodeBase: file:///C:/Program%20Files/Intel/OptaneShellExtensions/log4net.DLL
----------------------------------------
PinningServiceApi
    Assembly Version: 1.0.0.0
    Win32 Version: 1.0.0.0
    CodeBase: file:///C:/Program%20Files/Intel/OptaneShellExtensions/PinningServiceApi.DLL
----------------------------------------
System.ComponentModel.Composition
    Assembly Version: 4.0.0.0
    Win32 Version: 4.7.3056.0
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.ComponentModel.Composition/v4.0_4.0.0.0__b77a5c561934e089/System.ComponentModel.Composition.dll
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
    <system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.

Any ideas, why I get this error?
Thank you for you support!!

//Edit: I just tried two things, the filename of the shared database had points in it, like xx.xx.xx.kdbx, I renamed the file. And I gave me "Owner"-permissions on the shared file instead of "Contribute"-permissions. Unfortunately it made no difference, still the same error.

Regards,
Daniel

@DaKarli
Copy link

DaKarli commented Jun 23, 2019

Same issue here…
I just returned to 2.0.4.2 for the first setup which worked without any problem.
After the first setup it is no problem to update to 2.0.6.0. Everything works fine.
Seems that the problem has to do with the first setup.
I didn't upload a log as it is the same as before (except for the paths/names).
I hope this will help you to find the issue. ;-)

Regards, DaKarli.

@hgeorges
Copy link

hello all, i’ve unsubscribed from this thread about a dozen times, and i continue to receive notifications. anyway to fix this behavior?
thank you

@KoenZomers
Copy link
Owner

Same issue here…
I just returned to 2.0.4.2 for the first setup which worked without any problem.
After the first setup it is no problem to update to 2.0.6.0. Everything works fine.
Seems that the problem has to do with the first setup.
I didn't upload a log as it is the same as before (except for the paths/names).
I hope this will help you to find the issue. ;-)

Regards, DaKarli.

Thanks, that surely helps! I'll have a look at this once I get a chance.

@KoenZomers
Copy link
Owner

hello all, i’ve unsubscribed from this thread about a dozen times, and i continue to receive notifications. anyway to fix this behavior?
thank you

If you have unsubscribed using the option in the right column and still receive these, please contact GitHub support.

@KoenZomers
Copy link
Owner

This issue should be fixed in version 2.0.7.1. Please let me know if this does fix it for you.

@DanielHH87
Copy link

Good morning Koen,

I tested it and now I am able to add a kdbx-database from OneDrive and save it locally, without an exception. It is working now! Thank you pretty much!

Regards,
Daniel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants