public class StaticDataContainer<T> where T : IStaticData {
protected static Dictionary<int, T> data;
public static void init(string jsonString){
//It work fine in Unity,But in Xcode iOS,it will show an error below:
//ExecutionEngineException: Attempting to JIT compile method
//'System.Collections.Generic.Dictionary`2<int, AD>:.ctor ()'
//while running with --aot-only.
data = new Dictionary<int, T> ();
I refer to:http://answers.unity3d.com/questions/250803/executionengineexception-attempting-to-jit-compile.html
Your application makes use of some generic type that was missed during AOT compile.
And solution is:The problem can usually be fixed by including a "dummy" class that references the missing types.
But I dont' know what dummy class is.
How can I solve it?
Here's how I do it. I create a file with name AOTDummy.cs in a project with following structure (adapted for your problem):
public static class AOTDummy
{
public static void Dummy()
{
System.Collections.Generic.Dictionary<int, AD> dummy01;
}
}
Related
BaseTest.java:
private static ReportService reportService; // Calling report service interface
#BeforeSuite:
reportService = new ExtentReportService(getConfig()); // New instance of ExtentReportService.
#BeforeMethod:
reportService.startTest(testname); // Starting the test and passing the name and description of the test.
#AfterMethod:
reportService.endTest(); // Ending the test
#AfterSuite:
reportService.close(); // Closing the test
**ExtentReportService.java:** // Contains different extent API methods. (These are designed to be generic.)
protected static ExtentReports extent; // static instance of ExtentReports
protected static ExtentTest test; //static instance of ExtentTTest
#Override // StartTest method
startTest(Method method) {
testMetaData = getTestMetaData(method);
test=extent.startTest(testMetaData.getId(),testMetaData.getSummary());
}
#Override //End test method
endTest() {
extent.endTest(test);
extent.flush();
}
The above is my selenium code.
When I am executing my suite file with parallel="methods" and thread count="3", I am getting the following error: "com.relevantcodes.extentreports.ExtentTestInterruptedException: Close was called before test could end safely using EndTest.".
While debugging, I found that even before all endTest() in AfterMehtod were executed, AfterSuite was being called.
I tried different variations such that the code works, such as, removing static, calling endTest() in the test itself rather than after method, removing close() call from AfterSuite and many other variations. But still getting the same error.
I tried all the possible solutions given on the internet, but to no use.
Attaching a hierarchy file for the ExtentReport used in my project
I also the following solution given in StackOverflow:
Extent report :com.relevantcodes.extentreports.ExtentTestInterruptedException: Close was called before test could end safely using EndTest
Unsynchronized output
XMF file for parallel test.
ExtentReports Intialized in ExtentManager class using Singleton().
public class ExtentManager {
private static ExtentReports extent;
public static ExtentReports getInstance() {
if(extent == null) {
extent = new ExtentReports(System.getProperty("user.dir")+"\target\surefire-reports\html\extent.html", true, DisplayOrder.OLDEST_FIRST);
extent.loadConfig(new File(System.getProperty("user.dir")+"src\test\resources\extentconfig\ReportsConfig.xml"));
}
return extent;
}
}
Declared in TestBase class as global.
public ExtentReports repo= ExtentManager.getInstance();
public static ExtentTest test
Call startTest in public void onTestStart(ITestResult result)
test = repo.startTest(result.getName().toUpperCase());
Call endTest in CustomListener Class both in a)public void onTestFailure(ITestResult result); b)public void onTestSuccess(ITestResult result).
repo.endTest(test)
Call close() OR flush() in #AfterSuite in TestBase class but NOT both!
//repo.close();
repo.flush();
Note: I have ExtentReports ver-2.41.2, and TestNg ver-7.1.0.
After the above steps, error 'Getting closed before endTest call in Selenium using Extent Reports' got resolved.
Extent report generates each test successfully in the report.
Try it out!
I have a XAML page with WebView inside (for example MainPage.xaml). Also I have WinRT Component with class marked with [AllowForWeb] attribute. This component is referenced from project where MainPage.xaml located and in code-behind AddWebAllowedObject method is used. And I can't reference main project back because of circular dependency.
How to call MainPage.xaml.cs methods from component class? Very usual situation. Is there are some standard way to do it?
For example. I have a method inside RT component that could be called from JavaScript
public void ShowMessage(string message)
{
// I want to call here function from MainPage.xaml.cs
}
How to call MainPage.xaml.cs methods from component class? Very usual situation. Is there are some standard way to do it?
Yes, you can pass the method from MainPage.xaml.cs to Windows Runtime Component through delegate(Currently it's very limited to use delegate in Runtime Component using C#, see this case, so I use C++ as demo).
For Runtime Component Class MyClass.h:
public delegate Platform::String^ MyFunc(int a, int b);
public ref class MyClass sealed
{
public:
MyClass();
static Platform::String^ MyMethod(MyFunc^ func)
{
Platform::String^ abc=func(4, 5);
return abc;
}
};
And you can use the delegate in code behind like below:
using MyComponentCpp;
private void myBtn_Click(object sender, RoutedEventArgs e)
{
String abc=MyClass.MyMethod(MyMethod);
myTb.Text = abc;
}
private String MyMethod(int a, int b)
{
return (a.ToString() + b.ToString());//replace this line with your own logic.
}
And here is the complete Demo: TestProject.
Thankfully to #Elvis Xia who has gived me idea, I has found a solution how to do it without C++.
I have create a third project as Class Library. It doesn't has restrictions to use Action. This library I have referenced from main project and from WinRT component. Code of class inside library:
public class BridgeClass
{
public static event Action<string> MessageReceived;
public static void Broadcast(string message)
{
if (MessageReceived != null) MessageReceived(message);
}
}
Code inside main project with webview is:
// place somewhere
BridgeClass.MessageReceived += ShowMessage;
// ....... and add a method
void ShowMessage(string msg)
{
}
And now i can call this code from WinRT component:
public void ShowMessage(string message)
{
BridgeClass.Broadcast("lalala");
}
Im new to JNA. Im trying to access a method inside a DLL. I get the following error
Exception in thread "main" java.lang.UnsatisfiedLinkError: Error looking up function 'GetACSStatus': The specified procedure could not be found.
at com.sun.jna.Function.<init>(Function.java:179)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:347)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:327)
at com.sun.jna.Library$Handler.invoke(Library.java:203)
at com.sun.proxy.$Proxy0.GetACSStatus(Unknown Source)
at TestJNA.main(TestJNA.java:17)
Here is the code:
public class TestJNA {
public interface simpleDLLTest extends Library {
simpleDLLTest INSTANCE = (simpleDLLTest) Native.loadLibrary("IMV1", simpleDLLTest.class);
public NativeLong GetACSStatus();
}
public static void main(String[] args) {
simpleDLLTest sdll = simpleDLLTest.INSTANCE;
NativeLong result1 = sdll.GetACSStatus(); // calling function
System.out.println("GetACSStatus(): " + result1);
}
}
Please help.
You need to compile your code with extern "C" so that the symbols are exported without C++ name mangling.
Alternatively you can use the name from the symbol table as the function lookup name (you would need to use a FunctionMapperto get the special symbols).
I am new to Automapper.
I have added Nuget package - Automapper into my Manager (BLL) and DAL layer.
Now, below is related stuff:
Below is the statment of Manager library that giving me exception:
this.dataRepository.Update(Mapper.Map<StudentMaster>(studentDTO));
Exception is as follow:
Missing type map configuration or unsupported mapping.
Mapping types:
studentDTO -> StudentMaster
Admin.App.DTO.studentDTO-> Admin.App.DAL.StudentMaster
In case of select/where query on EF, it is working and able to map using
.Project().To<TReturn>()
I wrote an Autoconfiguration.cs file as follows:
public static class AutoMapperConfiguration
{
public static void Configure()
{
ConfigureStudentMasterMaps();
}
private static void ConfigureStudentMasterMaps()
{
Mapper.CreateMap<StudentMaster, studentDTO>();
}
}
Note:
Both the entity - StudentMaster (model) entity and StudentDTO have the same properties.
Please guide me how I could resolve this issue.
Thank You
See Getting-started https://github.com/AutoMapper/AutoMapper/wiki/Getting-started
CreateMap<**TSource, TDestination**>()
You must add
Mapper.CreateMap<studentDTO, StudentMaster>();
After mapping configuration call
Mapper.AssertConfigurationIsValid();
I had a similar problem, I forgot to register in the Global.asax
public class WebApiApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
GlobalConfiguration.Configure(WebApiConfig.Register);
AutoMapperConfig.RegisterMappings();
}
}
I need some help in auto-registering generics using StructureMap. Here is my scenario:
public class Object<T>
{
}
public interface IBehvior<T>
{
void DoSomething(T t);
}
public class Behvior<T> : IBehvior<Object<T>>
{
public void DoSomething(Object<T> t)
{
}
}
What I want to accomplish is something like:
var x = ObjectFactory.GetInstance<IBehavior<Object<int>>();
But when I run this statement, it gives me an error that no default instance is configured. In my StructureMap configuration I've used
ConnectImplementationsToTypesClosing(typeof(IBehavior<>))
But it still doesn't work!
Note that this worked fine if I didn't have Object. For example, if I have:
public class IntBehavior : IBehavior<int>
{
}
Everything works perfectly fine. But when I replace int with a generic type, it doesn't work!
Any ideas?
Ok I discovered the solution here:
http://lostechies.com/jimmybogard/2010/01/07/advanced-structuremap-custom-registration-conventions-for-partially-closed-types/