首先让我们说我不是一个经验丰富的开发人员,所以我很可能在这里完全错过了一些东西。
我正在VB .Net解决方案中实现Atlassian.NET SDK。在大多数情况下,一切正常,但是当我尝试直接使用LINQ提供程序时,出现以下错误:
Atlassian.Jira.dll中发生了'System.InvalidCastException'类型的未处理异常
附加信息:无法将类型为“ System.Linq.Expressions.PropertyExpression”的对象转换为类型为“ System.Linq.Expressions.ConstantExpression”。
完整的例外:
未处理System.InvalidCastException HResult = -2147467262
Message =无法将类型为“ System.Linq.Expressions.PropertyExpression”的对象转换为类型为“ System.Linq.Expressions.ConstantExpression”的对象。Source = Atlassian.Jira StackTrace:at atlassian.Jira.Linq.JqlExpressionVisitor.GetFieldNameFromBinaryExpression(BinaryExpression expression)in c:\ projects \ atlassian-net-sdk \ Atlassian.Jira \ Linq \ JlasExpressionVisitor.cs:第65行Linq.JqlExpressionVisitor.ProcessIndexedMemberEqualityOperator(BinaryExpression expression,Boolean equal)在c:\ projects \ atlassian-net-sdk \ Atlassian.Jira \ Linq \ JqlExpressionVisitor.cs:Atlassian.Jin.Linq.Jperlionion.Period表达式中的第142行c:\ projects \ atlassian-net-sdk \ Atlassian.Jira \ Linq \ JqlExpressionVisitor.cs:Atlassian.Jira.Linq.JqlExpressionVisitor中的第136行。1..ctor(IEnumerable\
1个源代码),位于C:\ Users \ v709092 \ Documents \ Visual Studio 2013 \ Projects \ JiraUpdater \ JiraUpdater \的JiraUpdater.JiraStuff.GetIssueByDetail(String summary)的System.Linq.Enumerable.ToArray [TSource](IEnumerable`1个源代码) JiraStuff.vb:位于C:\ Users \ v709092 \ Documents \ Visual Studio 2013 \ Projects \ JiraUpdater \ JiraUpdater \ Form1.vb位于JiraUpdater.Form1.ButtonMassUpdate_Click(Object sender,EventArgs e)的行33:System.Windows的第98行。 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)的System.Windows.Forms.Button.OnClick(EventArgs e)的System.Windows.Forms.Control.WmMouseUp(Message&m ,MouseButtons按钮,Int32单击)在System.Windows.Forms.ButtonBase.WndProc(Message&m)在System.Windows.Forms.Button.WndProc(Message&m)在System.Windows.Forms.ButtonBase.WndProc(Message&m)在System.Windows.Forms.Button.WndProc(Message&m) System.Windows。System.Windows.Forms.Control.ControlNativeWindow.WndProc(System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd,Int32 msg,IntPtr wparam,IntPtr lparam)处的Forms.Control.ControlNativeWindow.OnMessage(Message&m) System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID,Int32原因,Int32 pvLoopData)在System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG&msg) Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()上的System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32原因,ApplicationContext上下文)处的.Forms.Application.ThreadContext.RunMessageLoopInner(Int32原因,ApplicationContext上下文) .ApplicationServices。Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String []命令行)的WindowsFormsApplicationBase.DoApplicationModel(),位于System.AppDomain._nExecuteAssembly(RuntimeAssembly程序集,字符串,第81行)的JiraUpdater.My.MyApplication.Main(String [] Args) System.AppDomain.ExecuteAssembly()上的[] args)(Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()上的System.AppDomain.ExecuteAssembly(String assemblyFile,Evidence assemblySecurity,String [] args)在System.Threading上的System.Threading.ThreadHelper.ThreadStart_Context(Object state) System.Threading.ExecutionContext.Run(ExecutionContextexecutionContext,ContextCallback回调,对象状态,布尔值saveSyncCtx)在System.Threading.ExecutionContext处。在System.Threading.ThreadHelper.ThreadStart()处运行(ExecutionContext执行上下文,ContextCallback回调,对象状态)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提供程序如何处理查询的问题。早在很久以前就向开发人员报告了此问题,并因为开发人员不熟悉VB而将其标记为“无法解决”。
如果能为开发人员提供相关的详细信息以解决他们的问题,或者更实际地帮助指出我做错的事情,我将非常感谢您的帮助。
面向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进行查询相比,该问题被证明更快,更可靠。
高温超导
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句