对象引用未设置为顺序工作流中的对象实例 [英] object reference not set to an instance of object in sequential workflow

查看:55
本文介绍了对象引用未设置为顺序工作流中的对象实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我正在使用顺序工作流程2010.我在库下创建了一个名为GeneralLeave的文件夹。



当我执行以下代码时,我在行spfolder中出错。



我的代码是:

Hi,

I am using sequential workflow 2010. I created a folder named GeneralLeave under library.

When I execute the following my code I got error in line spfolder.

My code is:

 if (workflowProperties.Item["Action"].ToString() == "Separation" && workflowProperties.Item["Effective Date"].ToString()!="")
                {
                    
                    SPFolder myLibrary = SPContext.Current.Web.Folders["GeneralLeave"];
}



谢谢



Manohar


Thanks

Manohar

推荐答案

我们无法确切地告诉你为什么会遇到这个问题 - 实际的错误可能在你的代码的其他地方而且只出现在这里。

但基本上,发生了什么是。左边的元素之一。是 null

例如:

We can't tell you exactly why you get the problem - it's likely that the actual fault is elsewhere in your code and is only showing up here.
But basically, what is happening is that one of the elements to the left of a "." is null.
For example:
string s = a.b.c.d.ToString();

如果 a null ,你会收到错误。

如果 a 是一个值,但 ab null ,您将收到错误。

如果 ab 是一个值,但是 abc null ...



你得到这个想法。



在给出错误的线上方的线上放置一个断点并使用鼠标依次悬停在每个部分上 - 找到哪一个 null 你可以开始寻找你的代码让它为空的原因。


对不起,但它已经结束了我担心调试器。

if a is null, you will get the error.
if a is a value, but a.b is null, you will get the error.
if a.b is a value, but a.b.c is null...

You get the idea.

Put a breakpoint on the line above the one giving the error and use the mouse to hover over each part in turn - find which one is null and you can start looking for why your code has let it be null.

Sorry, but it's over to you and the debugger, I'm afraid.


同意 OriginalGriff [ ^ ]。



我给你的建议是使用
Agreed with OriginalGriff[^].

My advice to you is use
Convert.ToString(YourString);

而不是

YourString.ToString();





Here Convert.ToString如果YourString为NULL并且不会抛出异常,(YourString)将处理。



Here Convert.ToString(YourString) will handle if YourString is NULL and won't throw exception.


这篇关于对象引用未设置为顺序工作流中的对象实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆