让我们开始说我不是一个非常有经验的开发人员,因此我很可能在这里完全遗漏了一些东西。
我在VB .Net解决方案中实现Atlassian.NET SDK。在大多数情况下,一切都运行良好,但是当我尝试直接使用LINQ提供程序时出现以下错误:
未处理的类型' System.InvalidCastException'发生了 在Atlassian.Jira.dll
附加信息:无法投射类型的对象 ' System.Linq.Expressions.PropertyExpression'输入 ' System.Linq.Expressions.ConstantExpression'
完整的例外:
System.InvalidCastException未处理HResult = -2147467262
Message =无法转换类型的对象 ' System.Linq.Expressions.PropertyExpression'输入 ' System.Linq.Expressions.ConstantExpression&#39 ;.来源= Atlassian.Jira 堆栈跟踪: at Atlassian.Jira.Linq.JqlExpressionVisitor.GetFieldNameFromBinaryExpression(BinaryExpression) 表达)in C:\项目\ Atlassian的净SDK \ Atlassian.Jira \ LINQ的\ JqlExpressionVisitor.cs:行 65 at Atlassian.Jira.Linq.JqlExpressionVisitor.ProcessIndexedMemberEqualityOperator(BinaryExpression) 表达式,布尔等于) C:\项目\ Atlassian的净SDK \ Atlassian.Jira \ LINQ的\ JqlExpressionVisitor.cs:行 142 at Atlassian.Jira.Linq.JqlExpressionVisitor.ProcessEqualityOperator(BinaryExpression) 表达式,布尔等于) C:\项目\ Atlassian的净SDK \ Atlassian.Jira \ LINQ的\ JqlExpressionVisitor.cs:行 136 at Atlassian.Jira.Linq.JqlExpressionVisitor.VisitBinary(BinaryExpression) 节点) C:\项目\ Atlassian的净SDK \ Atlassian.Jira \ LINQ的\ JqlExpressionVisitor.cs:行 325 在System.Linq.Expressions.BinaryExpression.Accept(ExpressionVisitor 游客) 在System.Linq.Expressions.ExpressionVisitor.Visit(表达式节点) 在System.Linq.Expressions.ExpressionVisitor.VisitLambda [T](Expression`1 节点) 在System.Linq.Expressions.Expression`1.Accept(ExpressionVisitor visitor) 在System.Linq.Expressions.ExpressionVisitor.Visit(表达式节点) 在System.Linq.Expressions.ExpressionVisitor.VisitUnary(UnaryExpression 节点) 在System.Linq.Expressions.UnaryExpression.Accept(ExpressionVisitor 游客) 在System.Linq.Expressions.ExpressionVisitor.Visit(表达式节点) 在System.Linq.Expressions.ExpressionVisitor.VisitArguments(IArgumentProvider) 节点) 在System.Linq.Expressions.ExpressionVisitor.VisitMethodCall(MethodCallExpression) 节点) at Atlassian.Jira.Linq.JqlExpressionVisitor.VisitMethodCall(MethodCallExpression) 节点) C:\项目\ Atlassian的净SDK \ Atlassian.Jira \ LINQ的\ JqlExpressionVisitor.cs:行 252 在System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor 游客) 在System.Linq.Expressions.ExpressionVisitor.Visit(表达式节点) 在System.Linq.Expressions.ExpressionVisitor.VisitArguments(IArgumentProvider) 节点) 在System.Linq.Expressions.ExpressionVisitor.VisitMethodCall(MethodCallExpression) 节点) at Atlassian.Jira.Linq.JqlExpressionVisitor.VisitMethodCall(MethodCallExpression) 节点) C:\项目\ Atlassian的净SDK \ Atlassian.Jira \ LINQ的\ JqlExpressionVisitor.cs:行 252 在System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor 游客) 在System.Linq.Expressions.ExpressionVisitor.Visit(表达式节点) at Atlassian.Jira.Linq.JqlExpressionVisitor.Process(Expression expression)in C:\项目\ Atlassian的净SDK \ Atlassian.Jira \ LINQ的\ JqlExpressionVisitor.cs:行 42 at Atlassian.Jira.Linq.JiraQueryProvider.Execute(Expression expression,Boolean isEnumerable)in C:\项目\ Atlassian的净SDK \ Atlassian.Jira \ LINQ的\ JiraQueryProvider.cs:行 44 at Atlassian.Jira.Linq.JiraQueryProvider.Execute(Expression expression)in C:\项目\ Atlassian的净SDK \ Atlassian.Jira \ LINQ的\ JiraQueryProvider.cs:行 39 at atlassian.Jira.Linq.JiraQueryable`1.GetEnumerator()in c:\ projects \ atlassian-net-sdk \ Atlassian.Jira \ Linq \ JiraQueryable.cs:line 29 在System.Linq.Buffer1..ctor(IEnumerable\
1来源) 在System.Linq.Enumerable.ToArray [TSource](IEnumerable`1 source) 在C:\ Users \ v709092 \ Documents \ Visual Studio中的JiraUpdater.JiraStuff.GetIssueByDetail(字符串摘要) 2013 \ Projects \ JiraUpdater \ JiraUpdater \ JiraStuff.vb:第33行 在C:\ Users \ v709092 \ Documents \ Visual Studio中的JiraUpdater.Form1.ButtonMassUpdate_Click(Object sender,EventArgs e) 2013 \ Projects \ JiraUpdater \ JiraUpdater \ Form1.vb:第98行 在System.Windows.Forms.Control.OnClick(EventArgs e) 在System.Windows.Forms.Button.OnClick(EventArgs e) 在System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) 在System.Windows.Forms.Control.WmMouseUp(消息& m,MouseButtons按钮,Int32点击) 在System.Windows.Forms.Control.WndProc(消息& m) 在System.Windows.Forms.ButtonBase.WndProc(消息& m) 在System.Windows.Forms.Button.WndProc(消息& m) 在System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) 在System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) 在System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd,Int32 msg,IntPtr wparam,IntPtr lparam) 在System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) 在System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr) dwComponentID,Int32原因,Int32 pvLoopData) 在System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32) 原因,ApplicationContext上下文) 在System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32) 原因,ApplicationContext上下文) 在Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun() 在Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel() 在Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String [] 命令行) 在JiraUpdater.My.MyApplication.Main(String [] Args)中:第81行 在System.AppDomain._nExecuteAssembly(RuntimeAssembly程序集,String [] args) 在System.AppDomain.ExecuteAssembly(String assemblyFile,Evidence assemblySecurity,String [] args) 在Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() 在System.Threading.ThreadHelper.ThreadStart_Context(对象状态) 在System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext,ContextCallback回调,对象状态,布尔值 preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext,ContextCallback callback,Object state,Boolean preserveSyncCtx) 在System.Threading.ExecutionContext.Run(ExecutionContext executionContext,ContextCallback回调,对象状态) 在System.Threading.ThreadHelper.ThreadStart()InnerException:
我的代码是项目WIKI页面上的示例代码的直接转换。
Dim myJira As Jira = Jira.CreateRestClient("JiraServer", "username", "password")
Dim myIssueQuery = From i In myJira.Issues
Where i.Project = "JiraProjectName"
Select i
Console.WriteLine( myIssueQuery.Count())
在做了一些研究之后,我已经确信这是LINQ提供程序如何处理查询的问题。很久以前就向开发人员报告了此issue,标记为"赢得了"因为开发人员不熟悉VB。
我非常感谢您提供开发人员相关详细信息以解决问题,或者更真实地帮助指出我做错了什么。
答案 0 :(得分:0)
Jira的Api可能会变得有点复杂,很容易最终使用不能做你想要的旧版本。我使用nuget包“Atlassian.SDK”获得了最好的结果。
有了这个,做你想做的事是相对微不足道的。这是C#代码,但我猜vb.net不会有太大的不同。
this.JiraConnection = Jira.CreateRestClient(jiraUrl, jiraUser, jiraPassword);
string jql = "project = TC";
IEnumerable<Issue> issues = this.JiraConnection.GetIssuesFromJql(jql, 100);
这允许您使用Jira查询语言来解决您想要的问题,这在我的测试中证明更快,并且比使用Linq查询更可靠。
HTH