Monday, March 29, 2010

-- How to get the path of the assembly currently executing



In order to get the path of the current executing assembly in C#:

// Get the current running assembly code
System.Reflection.Assembly myAssembly = System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName;

//Now we can get the path where the current code is running
String myPath = System.IO.Path.GetDirectoryName(myAssembly);




Wednesday, March 17, 2010

No errors when debugging but breakpoints are not hit on Visual Studio



In order to fix this problem you need to be sure that all the modules in your project are enabled for debugging, some times the main is enabled but the rest are not, this would give you the apparency of no errors but breakpoints on the modules not enabled will cause the debugging to stop.

To enable debugging right click on each project and select "Properties".
A window like the one on the image below should appear.
On 'Enable ASP.NET Debugging" select "True"
Click "Apply" then close.
The debug has been enabled for this module, repeat the process for all projects.






Friday, March 12, 2010

Remote desktop connection "The local policy of this system does not permit you to logon interactively"



If you are not an administrator and try to use the Remote Desktop Connection tool, you may receive the following error message:

The local policy of this system does not permit you to logon interactively.

This issue occurs because the user account is not a member of the local Remote Desktop Users group.

To resolve this issue, add allowed users to the Remote Desktop Users list:
  1. Click Start, point to Settings, and then click Control Panel.
  2. Double-click System, and then on the Remote tab, click Select Remote Users.
  3. Click Add type in the user account name, and then click OK.

    If you are adding more than one user name, use a semicolon to separate the names.
Note: Adding users to the Remote Desktop Group requires that you are logged on through an administrator account.

Also, make sure that the Remote Desktop Users group has sufficient permissions to log on through Terminal Services. To do this, follow these steps:
  1. Click Start, click Run, type secpol.msc, and then click OK.
  2. Expand Local Policies, and then click User Rights Assignment.
  3. In the right pane, double-click Allow logon through Terminal Services. Make sure that the Remote Desktop Users group is listed.
  4. Click OK.
  5. In the right pane, double-click Deny logon through Terminal Services. Make sure that the Remote Desktop Users group is not listed, and then click OK.
  6. Close the Local Security Settings snap-in

Source:
http://support.microsoft.com




Wednesday, March 3, 2010

How to call a JavaScript function from a Java applet




Calling a JavaScript function from a Java applet is really simple; in order to approach it we need to use the showDocument method, see the example below of the Java applet:

import java.net.*;
import java.applet.*;


public class MyApplet extends Applet
{
public void init()
{
String msg = "Hello World...";

try {
URL _url = new URL("javascript: callme(\"" msg "\")"
getAppletContext().showDocument( _url) );
}
catch (MalformedURLException e) {
e.toString();
}
}
}


Next we need the JavaScript function:

<script language="JavaScript" type="text/javascript">
function callme(msg)
{
try{
alert(msg);
}
catch(e){
alert(e);
}
}
</script>

Finally we code the HTML code:

<APPLET CODE="MyApplet.class"
NAME="myApplet"
MAYSCRIPT
HEIGHT=15
WIDTH=15>
</APPLET>