首页 \ 问答 \ 如何通过反射从控制台应用程序获取Web应用程序组件信息(How to get web application assembly information from console application by reflection)

如何通过反射从控制台应用程序获取Web应用程序组件信息(How to get web application assembly information from console application by reflection)


我需要获取控制器/操作方法名称的列表
的mvc网络应用程序
从控制台应用程序。

所以我用反射来做到这一点。
我将Web应用程序的.dll引用到控制台应用程序。
但是我无法从控制台应用程序源获取Web应用程序的程序集信息。

var check = AppDomain.CurrentDomain.GetAssemblies();
var assembly = AppDomain.CurrentDomain.GetAssemblies()
.First(x =>x.ManifestModule.Name == "RedStar.WebApp.dll");

抛出这个exceptipn'System.InvalidOperationException''序列不包含匹配的元素'



I need to get a list of controller/action method names
of mvc web application
from a console application.

So I use reflection to do this.
I referenced web application's .dll to console application.
But I can not get web application's assembly information from console application source.

var check = AppDomain.CurrentDomain.GetAssemblies();
var assembly = AppDomain.CurrentDomain.GetAssemblies()
.First(x =>x.ManifestModule.Name == "RedStar.WebApp.dll");

throws this exceptipn 'System.InvalidOperationException' 'Sequence contains no matching element'


原文:https://stackoverflow.com/questions/41159916
更新时间:2023-10-11 17:10

最满意答案

检查该jar是否存在于Classpath中。 这个jar应该放在Tomcat安装目录的lib文件夹中,或者它应该打包在web应用程序的lib文件夹中。


Check if the jar is present in the Classpath. Either that jar should be inside the lib folder of Tomcat installation directory or it should be packaged in the lib folder of the web app.

相关问答

更多
  • 检查该jar是否存在于Classpath中。 这个jar应该放在Tomcat安装目录的lib文件夹中,或者它应该打包在web应用程序的lib文件夹中。 Check if the jar is present in the Classpath. Either that jar should be inside the lib folder of Tomcat installation directory or it should be packaged in the lib folder of the web ...
  • 最后,我设法让它发挥作用。 这是如何: MyApplication.java package com.somecompany; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class MyApplication { public static ...
  • 我发现了这个问题。 我猜想问题出现在DB中。 在Vaadin应用程序中配置我的数据库连接包括一个context.xml文件,该文件与配置的DB连接,而且只是Tomcat的context.xml。 我所做的是我从这个context.xml获取连接配置并将其直接粘贴到Liferay的Tomcat中的context.xml中,一切正常。 这就是为什么这个Vaadin应用程序在部署在独立的Tomcat服务器上时起作用的原因,因为它在Tomcat本身覆盖了context.xml,而在Liferay上完成时并非如此。 ...
  • 问题是我在Vaadin的观点/页面的名称。 在我的电脑上,有了Spring,我为每个视图命名,并且没问题。 但在Tomcat上,他想要一个没有任何名字的页面,换句话说,就是页面名称“”。 我将登录页面从“登录”更改为“”; 然后全部运行完美。 有用 ! The problem is the names of my views/pages in Vaadin. On my computer, with Spring, I have a name for each view, and it is ok. But ...
  • 我认为您需要从USER对象中删除静态final。 任何静态final都只能为整个应用程序创建一次。 您需要它作为实例变量。 例如 private User USER = null; 并不是 private static final User USER = null; I think you need to remove the static final from your USER object. Anything static final can only be created once ever f ...
  • 正如Sascha Frinken所建议的那样,解决方案是: VaadinService.getCurrentRequest().getWrappedSession().setAttribute("userName", "test-user"); As suggested by Sascha Frinken, the solution is: VaadinService.getCurrentRequest().getWrappedSession().setAttribute("userName", "tes ...
  • 当我尝试在openshift中部署Vaadin应用程序时,我遇到了类似的问题。 如果你的生产模式等于false,则openshift没有将scss编译为css并不重要。 使主题工作的唯一方法是预编译scss然后部署。 为此,您可以使用Eclipse插件或通过命令行执行此操作。 您可以在此处找到有关它的更多信息: https : //vaadin.com/book/es/-/page/themes.sass.html I experienced a similar problem when I tried t ...
  • 它抱怨它无法找到已编译的widgetset。 Vaadin在客户端使用GWT。 GWT使用Java编写客户端代码成为可能,但浏览器不了解Java,因此必须将GWT Java代码编译为Javascript,以便浏览器能够执行它。 要编译项目的widgetset,可以在项目的根目录中说mvn clean install 。 如果您不使用包含客户端GWT代码的任何插件,也没有在项目中拥有自己的GWT代码,那么您可以使用标准的预编译com.vaadin.DefaultWidgetSet 。 默认widgetset是 ...
  • 我找到了dCharts小部件,但我不知道如何使用。 我在这里问: 如何在Vaadin项目中使用dCharts Widget? I have found dCharts widget, but I have no idea how to use. I asked here: How use dCharts Widget in a Vaadin project?

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。