这确实是一个基本问题,可能会重复。谁能告诉我.Net中任何程序生成的错误信息的有用性。
今天,我收到了一个错误消息“发现歧义匹配”。在将实体保存在数据库中(使用EF4)时,我无法弄清楚为什么会出现此错误,根本原因是什么。附件是相同的按扣。
这是完整的错误详细信息,
System.Reflection.AmbiguousMatchException was unhandled by user code
Message=Ambiguous match found.
Source=mscorlib
StackTrace:
at System.RuntimeType.GetPropertyImpl(String name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers)
at System.Type.GetProperty(String name)
at IAA.Data.EntityFramework.RepositoryWithTypedId`2.SaveOrUpdate[T](T entity)
at ABC.XYZ.ApplicationServices.AcknowledgementManagementService.SaveOrUpdate(AcknowledgementFormViewModel acknowledgementFormViewModel) in E:\RA\ABC.XYZ\app\ABC.XYZ.ApplicationServices\AcknowledgementManagementService.cs:line 123
at ABC.XYZ.Web.Controllers.AcknowledgementsController.Acknowledgements(AcknowledgementFormViewModel acknowledgementFormViewModel) in E:\RA\ABC.XYZ\app\ABC.XYZ.Web.Controllers\AcknowledgementsController.cs:line 68
at lambda_method(Closure , ControllerBase , Object[] )
at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClassd.<InvokeActionMethodWithFilters>b__a()
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)
Run Code Online (Sandbox Code Playgroud)
InnerException:
首先,这是我使用swing的第一周,如果我的问题太明显,那就很抱歉.此外,我需要使用标准java库的解决方案,因为这是用于家庭作业,我不允许使用奇怪的库.
我正在使用JLabel和ImageIcon在JFrame上显示图像.现在我想将屏幕上的图像旋转到任意角度.我发现了一些关于Graphics2D的东西,但我找不到这样做的方法.
由于我发现的解决方案不起作用或我不理解它们,我对旋转ImageIcon或JLabel的任何解决方案感兴趣.由于我将图像定位在JLabel上的setBounds,旋转JLabel将是一个更好的解决方案我想(这样我也不会被迫保存ImageIcon对象).
感谢您的关注,抱歉我的英语不好.
编辑...要在屏幕上显示图像,请执行下一步:
JFrame frame = new JFrame("Something");
frame.setLayout(new FlowLayout()); //for example
JPanel panel = new JPanel();
panel.setLayout(null);
ImageIcon playerSprite = new ImageIcon("rute/to/file.png");
JLabel player = new JLabel(playerSprite);
panel.add(player);
player.setBounds(10,10,36,52); //for example
frame.getContentPane().add(panel);
frame.setVisible(true);
Run Code Online (Sandbox Code Playgroud)
恢复,我该如何旋转这个IconImage或JLabel.如果您认为更好,我可以使用其他方法来显示图像.如果解决方案是使用Graphics2D,就像我看到的那样,我将欣赏到达此类对象的解决方案,稍后将旋转后的图像返回到ImageIcon,因为当我尝试这个时......
ImageIcon imagePlayer = new ImageIcon("img/stand.png");
Image image = imagePlayer.getImage();
Graphics2D g = (Graphics2D)image.getGraphics();
Run Code Online (Sandbox Code Playgroud)
在执行时,答案就是这个......
Exception in thread "main" java.lang.UnsupportedOperationException: getGraphics() not valid for images created with createImage(producer)
Run Code Online (Sandbox Code Playgroud)
第2版......现在我正在使用这段代码.图像旋转但旧的未旋转图像仍保留在新图像下的屏幕上.将一个名为stand.png的png图像放在同一目录中,您将看到它.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import …Run Code Online (Sandbox Code Playgroud) 这么多的Ruby语言的方法,而不是语法,所以我希望能够找到%q,%w等等,定义为方法Kernel类.但是,他们不在那里.
那他们在哪里定义?他们是语言关键词吗?
我想使用openMP并行生成伪随机数,如下所示:
int i;
#pragma omp parallel for
for (i=0;i<100;i++)
{
printf("%d %d %d\n",i,omp_get_thread_num(),rand());
}
return 0;
Run Code Online (Sandbox Code Playgroud)
我已经在Windows上测试了它,并且我获得了巨大的加速,但每个线程生成了完全相同的数字.我已经在Linux上测试了它并且我得到了巨大的减速,8核处理器上的并行版本比顺序慢了大约10倍,但是每个线程生成了不同的数字.
有没有办法同时加速和不同的数字?
编辑27.11.2010
我想我已经用乔纳森杜尔西的一个想法解决了这个问题.似乎下面的代码在linux和windows上运行得很快.数字也是伪随机的.你怎么看待这件事?
int seed[10];
int main(int argc, char **argv)
{
int i,s;
for (i=0;i<10;i++)
seed[i] = rand();
#pragma omp parallel private(s)
{
s = seed[omp_get_thread_num()];
#pragma omp for
for (i=0;i<1000;i++)
{
printf("%d %d %d\n",i,omp_get_thread_num(),s);
s=(s*17931+7391); // those numbers should be choosen more carefully
}
seed[omp_get_thread_num()] = s;
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
PS.:我还没有接受任何答案,因为我需要确定这个想法是好的.
您好我需要知道如何在C#中检查相同类型的对象.
场景:
class Base_Data{}
class Person : Base_Data { }
class Phone : Base_data { }
class AnotherClass
{
public void CheckObject(Base_Data data)
{
if (data.Equals(Person.GetType()))
{ //<-- Visual Studio 2010 gives me error, says that I am using 'Person' is a type and not a variable.
}
}
}
Run Code Online (Sandbox Code Playgroud) 我有POJO课程:
class Ticket {
private int id;
private double cost;
private Date time;
private List<Place> places;
// Getters and setters here
}
class Place {
private int row;
private int place;
// Getters and setters here
}
Run Code Online (Sandbox Code Playgroud)
然后我创建一张票和一些地方:
Ticket ticket = new Ticket();
ticket.setCost(58.7);
ticket.setTime(new Date());
Place place1 = new Place();
place1.setRow(1);
place1.setPlace(2);
ticket.addPlace(place1);
Place place2 = new Place();
place2.setRow(3);
place2.setPlace(4);
ticket.addPlace(place2);
Run Code Online (Sandbox Code Playgroud)
现在我想将它保存到DB:
session.insert("insertTicket", ticket);
session.commit();
Run Code Online (Sandbox Code Playgroud)
在MapperConfig.xml中,我写这行:
<insert id="insertTicket" parameterType="Ticket">
INSERT INTO tickets (cost, time) VALUES (#{cost}, #{time})
</insert>
Run Code Online (Sandbox Code Playgroud)
如何在自动模式下保存 …
我正在编写一个需要使用这两个单元的组件
DesignIntf,DesignEditors
当我构建我的包时,我得到了错误
找不到档案:'DockForm.dcu'
当我将"designide.dcp"添加到包的"requires"部分时,它构建并编译就好了.
但是,当我将组件添加到新项目时(在设计时,它可以工作.我可以更改所有属性等......但是,它在运行时不起作用.当我使用组件运行应用程序时在主窗体上,我再次得到""找不到文件:'DockForm.dcu'"错误
请帮忙
谢谢
我正在使用Solr附带的Jetty/Solr构建,并希望在后台而不是在终端中运行它.
现在我开始它java -jar start.jar但我想它登录到文件并在服务器的后台运行,以便我可以关闭终端窗口.
我确定有一些我找不到的java配置.
我已经尝试过,java -jar start.jar > log.txt &但没有运气仍然输出到终端窗口.
谢谢.
有没有办法从命令行编译C++ Builder项目(特定的构建配置)?
就像是:
CommandToBuild ProjectNameToBuild BuildConfiguration ...
Run Code Online (Sandbox Code Playgroud) 将ASP.NET Web应用程序限制为仅为给定数量的并发用户提供服务的好方法是什么?
一些要求是:
java ×3
c# ×2
asp.net ×1
automation ×1
build ×1
c ×1
c++builder ×1
collections ×1
components ×1
delphi ×1
delphi-2010 ×1
exception ×1
jetty ×1
jlabel ×1
licensing ×1
mybatis ×1
object ×1
openmp ×1
persistence ×1
random ×1
rotation ×1
ruby ×1
solr ×1
sql ×1
swing ×1
terminal ×1