My application is almost complete and I needed to change the package names. So I refactored the names and after I renamed the package that contained the MAIN class, this warning is getting displayed - " No definition found for exported static routine: .main(String[])".
On googling, I found that this is because compiler didn't find any entry points for the application and that's why the application is not getting loaded in to the simulator/device.
Can anybody please help me on this ?
Thanks in advance !!
As the error message implies, you must have a method with the signature:
public static void main(String[] args) {
}
defined in one of your classes. It doesn't matter which but it is common to define it in the class that extends Application or UiApplication since this method creates the Application or UiApplication object and enters the event dispatcher. You must have had such a method at some point if you ever ran the application on the simulator or device.
Related
I am trying to implement receive/push azure notification with google cloud messaging in Android Xamarin project
I have followed "Get started with Notification Hubs with Xamarin for Android" article and everything went fine and I can receive notification!
in this article we add these lines of code in MainActivity class
GcmClient.CheckDevice(this);
GcmClient.CheckManifest(this);
GcmClient.Register(this, Constants.SenderID);
but we are going for some reason not use activity class, and I need to apply mentioned codes in none activity class ,
as the input "this" for above codes are "Android.Content.context"
,I tried to get Android.Content.context and send as parameter to CheckDevice and CheckManifest method
var _this = Android.App.Application.Context;
GcmClient.CheckDevice(_this);
GcmClient.CheckManifest(_this);
but i get following Error in "GcmClient.CheckManifest(_this);" line
I am quite new in this area but I guess i missing to add some info in manifest file, I really appreciate if you help me how we implement mentioned codes about GcmClient in non activity class in order to implement notification
Thanks
As stated in this forum, it is thrown by System.Reflection when the latter catches an exception, while attempting to query / manipulate / invoke one of the member of the instance reflected upon. Also based from this thread, "TargetInvocationException masks the real exception by telling you that it crashed during "a method invocation", usually through something.Invoke. What you have to do is look at the InnerException property of the exception object (the TargetInvocationException object), this will give you the actual exception that was thrown, with a more useful stack trace."
I am stuck in a situation, in which i am creating a test project in ASP.Net MVC, here i am testing a Method which is actually using to download a file, so whenever i am trying to test this method it gives
OutputStream is not available when a custom TextWriter is used
Error in Response.BinaryWrite(), everything is fine except this, can anyone tell me how to resolve this exception, i am using MOQ dll for Mocking, Please suggest me to get rid of this situation.
HttpContext.Current.Response.BinaryWrite()
This is the line which is actually generating exception, now i have a question that- Is this good to test a download method or i have to leave it, if it is good then how to resolve this issue.
Thanks.
If you are writing a unit test you generally don't want to be writing a test that have dependencies that you can't control (e.g. writing to the database, filesystem or output stream). You can also assume that the Response.BinaryWrite does what it is supposed to.
You could do something like this to get around the error you are seeing.
public interface IBinaryWriter
{
void BinaryWrite(byte[] buffer);
}
public class ResponseBinaryWriteWrapper : IBinaryWriter
{
public void BinaryWrite(byte[] buffer)
{
HttpContext.Current.Response.BinaryWrite(buffer);
}
}
This will give you the ability to inject the IBinaryWriter into the class you want to test as a mock and then you can check that BinaryWrite is called with the correct byte array. In your production code you then inject your concrete ResponseBinaryWriterWrapper class.
plz tell me can we extend Uiapplication and application class in blackberry.?
if yes then how?
You would just have separate classes extending them. It's your
public static void main(String[] args)
method that is going to determine behavior: you would look at the argument coming in and decide whether to launch the UiApplication or Application.
Create a second project in the workspace, and in properties set it up as an "alternate entry point for " and then you can specify the arguments given to main.
Generally you'd make the 'base' project start the Application (a service I'm assuming - e.g. automatic startup, system module) and then you'd set the alternate entry point to pass "GUI" or some other token to main, and you'd create your UiApplication instance instead.
In a Grails 1.1 plugin, I'm trying to load a class from the main application using the following code:
class MyClass {
static Map getCustomConfig(String configName){
return new ConfigSlurper().
parse(ApplicationHolder.application.classLoader.loadClass(configName))
}
}
Where configName is the name of the class in $MAIN_APP/grails-app/conf containing the configuration info. However, when the code above runs within a unit test applicationHolder.application returns null, causing the method above to throw a NullPointerException. A Grails JIRA issue was created for this problem, but it has been marked as fixed despite the fact that problem appears to still exist.
I know that within the plugin descriptor class I can access the main application (an instance of GrailsApplication) via the implicit application variable. But the code shown above is in not in the plugin descriptor.
Is there a way that I can load a class from the main application within a plugin (but outside the plugin descriptor)?
Thanks,
Don
It turns out there are 2 possible answers.
The Right Answer
GrailsApplication is not available in unit tests, so for the code above to work it should be an integration test
The Hack that Works
Change
parse(ApplicationHolder.application.classLoader.loadClass(configName))
to
parse(MyClass.classLoader.loadClass(configName))
im calling an actionscript class from my main mxml file. the actionscript class is responsible for calling a web service and handling the response, however im having trouble and keep getting the following error; (im new to flex btw)
Error #1009: Cannot access a property or method of a null object reference.
my code goes as follows;
public function getSites(argWsdl:String):void{
ws = new WebService();
ws.loadWSDL(argWsdl);
ws.getSites.addEventListener(ResultEvent.RESULT,echoResultHandler);
ws.getSites();
}
public function echoResultHandler(event:ResultEvent):void {
var siteField:ArrayCollection = event.result as ArrayCollection;
Application.application.setSiteField(siteField);
}
when i run the debugger the code never reaches the result hanlder and i see the #1009 error in the variable list.
any ideas?
looks like you have it sorted, but just to add more information in case someone else comes along to this question, you generally see this error when you are trying to use something that hasn't been created yet. A lot of the time you will see it when trying to access UI components that have not yet been created (its good to rely on the creationComplete event for these sort of things), but in this case it looks like you are using the webservice before it is completely ready (the wsdl hasnt been loaded yet).
Just so you know, you can also define your webservices in mxml (mx:webservice) and specify the wsdl there or you can also load the wsdl later on from a configuration file afterwards just by referencing the ID.
sorted it out,
i needed to created a loadEvent and loadhandler. Once loadWsdl is called the loadhandler specifies the laodHandler to use, inside the loadHandler i call the method name as seen in the wsdl
thanks Ryan,
the main reason im using a seperate actionscript class is so i can reuse the same web service calls across my components without having to retype the same code. I couldnt think of a better way to do this - maybe a could have done the same with a custom component