View previous topic :: View next topic |
Author |
Message |
ronchese
Joined: 30 Dec 2007 Posts: 30
|
Posted: Tue Oct 23, 2012 21:58 Post subject: |
|
|
Wow! I dont know if possible, but if so, look at my face: *_*
hehe |
|
Back to top |
|
|
Baaleos
Joined: 02 Sep 2007 Posts: 830
|
Posted: Tue Oct 23, 2012 22:29 Post subject: |
|
|
Do you want a copy of the entire project?
Im having trouble getting it to work for nwserver
It keeps failing when creating the remote thread
Gets 0 back as the threadHandle
Code: |
public ThreadManager CreateThread(IntPtr startAddress, IntPtr parameter, CreationAttributes attributes)
{
IntPtr threadHandle;
InsufficientRightsException.Assert(Access, AccessRights.ProcessCreateThread);
threadHandle = Kernel32.CreateRemoteThread(Handle, IntPtr.Zero, IntPtr.Zero, startAddress, parameter, attributes, IntPtr.Zero);
if (threadHandle == IntPtr.Zero)
{
throw new InvalidHandleException(threadHandle, "CreateRemoteThread");
}
else
{
return new ThreadManager(threadHandle);
}
}
|
|
|
Back to top |
|
|
ronchese
Joined: 30 Dec 2007 Posts: 30
|
Posted: Wed Oct 24, 2012 0:29 Post subject: |
|
|
hmmm.. I'm afraid I can't help on it.
It would be a real hard job to do, specially thinking that we are good already with stuff we have working atm. |
|
Back to top |
|
|
Baaleos
Joined: 02 Sep 2007 Posts: 830
|
Posted: Tue Nov 13, 2012 15:29 Post subject: |
|
|
ronchese wrote: | I would go one of these ways:
-------------------------------
1. System.IO.FileInfo
Code: |
private SortedList<string, DateTime> _cachedDates = new SortedList<string, DateTime>();
//...
//...
var fi = new FileInfo("path");
if (fi.LastWriteTime > _cachedDates["key"]) RefreshCache("key");
|
Once it will be quicker than performing a hash.
-------------------------------
Or
2. System.IO.FileSystemWatcher
This way you can immediately invoke the compiler whenever the file changes.
. |
Hi Ron,
I am planning on implimenting this FileSystemWatcher as mentioned before.
Can you tell me - is the current c++ dll source code setup to allow the caching?
Eg- the code for the Execute Method looks linear,
but I see where it is commented out, with comments suggesting that to hold it in memory, to just uncomment.
But will that truly keep it in memory without memory leaks?
Eg - Will it not just create a new instance over the top of the old one?
Code: |
if (Parameters)
{
try {
// This is the space where data can be exchanged with NWN
Log("* Got parameters: %s.\n", Parameters);
//the line below is a sample how to instantiate the dotnetassembly
// use this to hold the class in memory, to avoid internally reloading
// it for every call (we reload it internally so we can use Reflection)
// IF YOU DO THIS, don't forget to free the instantiated object when no needed anymore
[b]//NwnxAssembly::Execution ^e = gcnew NwnxAssembly::Execution();[/b]
//convert to a .NET string
System::String ^strParams = "";
std::string s=Parameters;
strParams = gcnew System::String(s.c_str());
//execute and return
System::String ^strReturn = NwnxAssembly::Execution::Execute(strParams);
char* wch = (char*)(void*)System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(strReturn);
strncpy(Parameters, wch, strlen (Parameters));
//dispose
free(wch);
delete strReturn;
delete strParams;
}
catch (...) {
strncpy(Parameters, "Error on executing Assembly", strlen (Parameters));
}
}
|
Does this work - or would I need to do a
if not Null check around it? |
|
Back to top |
|
|
Zunath
Joined: 06 Jul 2006 Posts: 183
|
Posted: Thu Dec 27, 2012 1:08 Post subject: |
|
|
Would you be willing to share the C# version Baaleos? I get sick of dealing with VB at work - no need for me to mess with it in my spare time |
|
Back to top |
|
|
Zunath
Joined: 06 Jul 2006 Posts: 183
|
Posted: Thu Dec 27, 2012 3:23 Post subject: |
|
|
Scratch that - was able to get it converted. Didn't realize it was less than 1000 lines long.
However I am getting the following error on both VB and C# versions. Not sure where to go with this - can anyone assist?
Error message in the nwnx.txt log:
* An error occured while loading extension dotnetplugin (14001: The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for more detail. ) |
|
Back to top |
|
|
Baaleos
Joined: 02 Sep 2007 Posts: 830
|
Posted: Thu Dec 27, 2012 3:34 Post subject: |
|
|
I will try to get this made public in next few days.
Holidays , and now work tomorrow makes for busy schedule.
Although- in case u wana know how I converted his nwnx assembly over to c# .
There are online web pages where u can paste vb code in, and it generates the c# equiv.
I did this for the majority of the classes.
Some classes I didn't need to convert over.
It's really just the execution, and regexp classes- possibly the command line too. |
|
Back to top |
|
|
Vanes^
Joined: 05 Jun 2011 Posts: 4
|
Posted: Sun Mar 03, 2013 20:46 Post subject: C# Version |
|
|
I just quickly stitched this together for anyone interested. It's fully working in C# instead of VB.NET conversion with some things from this thread added in to help installation and stuff.
Allow for the creation of a folder for uncompiled .cs files and then using them for implementing stuff in the server without recompiling the nwnx_dotnet.dll.
Added a ini setting for this in the NWNX.ini.
https://dl.dropbox.com/u/1872687/DotNetPlugin.7z
(A lot of thanks to Baaleos for his handy snippets! Definitely check out his version instead once it pops up )
Update: Wasn't working, now is.
Last edited by Vanes^ on Sun Mar 03, 2013 21:47; edited 1 time in total |
|
Back to top |
|
|
Baaleos
Joined: 02 Sep 2007 Posts: 830
|
Posted: Sun Mar 03, 2013 21:17 Post subject: |
|
|
I uploaded the source of my C# NWNXReflector project (which is just the different name I gave the nwnxAssembly project when I converted to C#)
http://nwvault.ign.com/View.php?view=Other.Detail&id=1542
It is still pending approval.
One feature I added recently, was the ability to Point to 'Compiled' DLL's as well as Uncompiled cs files.
Using an uncompiled cs file will be slower to use when called from nwscript - as .Net will first have to compile the code.
However, if the cs files are compiled to dll by the admin/developer before hand - they can instead call the functions in the dll's instead - bypassing the compile step.
Can shave off alot of time depending on the functionality, if its pre-compiled. |
|
Back to top |
|
|
Zunath
Joined: 06 Jul 2006 Posts: 183
|
Posted: Mon Jul 14, 2014 0:50 Post subject: |
|
|
Baaeleos, can you repost your changes to somewhere else? With the vault down, I can't get to it now.
Thanks in advance man. |
|
Back to top |
|
|
Zunath
Joined: 06 Jul 2006 Posts: 183
|
Posted: Wed Dec 24, 2014 3:10 Post subject: |
|
|
It occurs to me that Baaleos sent this to me a long time ago, but I forgot to come back and post a download link to it.
Here's the link for anyone in the future looking for it:
https://www.dropbox.com/s/1hs685ik8etq2vx/DotNetPlugin.rar?dl=0
Thanks again for sending it on, Baaleos. |
|
Back to top |
|
|
|