|
Hello
May I consult you how did u solved this problem?
I have the similar problem
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
private delegate bool _B_B(byte O1, byte O2, byte O3, byte O4, byte O5);
private IntPtr hMod;
private _B_B funA;
if (chk = (hMod = LoadLibrary("my.dll")) != IntPtr.Zero)
if (chk = (pFunc = GetProcAddress(hMod, "funA")) != IntPtr.Zero)
funA = (_B_B)Marshal.GetDelegateForFunctionPointer(pFunc, typeof(_B_B));
private void button_Click(object sender, EventArgs e)
{
bool chk = false;
byte temp1 = 1, temp2 = 0, temp3 = 15, temp4 = 45, temp5 = 90;
try
{
if (!(chk = funA(temp1, temp2, temp3, temp4, temp5)))
MessageBox.Show("set fail!");
}
catch (Exception ex)
{
MessageBox.Show("fail!");
}
}
|
|
|
|
|
My friend I don't remember what the issue was, but it was certainly in C++ dll. And that is what I updated the original post/question.
Please double check C++ dll. Checkout this video tutorial
|
|
|
|
|
Hi Django_Untaken
did you solve this problem? I have the same problem.
Thank in advance
|
|
|
|
|
While deleting Images m getting following Error
the action cannot be completed because the file is open in w3wp.exe,can any one get me out this problem.
if (File.Exists(_sampleImgsPath))
{
File.Delete(_sampleImgsPath);
}
|
|
|
|
|
Close the file before you try to delete it.
The message is pretty explicit: it even tells you which process is holding the file open. So, if that is your app, then start looking through your code to find out where you open it, but don't close it again. We can't do that for you - we don't have access to your code!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
As OG says, this is because the file needs to be closed first. I suspect you've got the image opened directly in your website; w3wp.exe refers to the IIS worker process that hosts your web page.
This space for rent
|
|
|
|
|
The most common cause of this is that you have created the image yourself using an Image or Bitmap class, saved the image but not disposed the Image or Bitmap class;
myImg.Save(path);
myImg.Dispose(); // <-- need this
|
|
|
|
|
Actually am going to delete the uploaded images. I have not used any Image or Bitmap, using HttpPostedFile class to upload images.
HttpPostedFile htp = (HttpPostedFile)dt.Rows[i]["postedfile"];
destination = Server.MapPath("~/ClientImages" + "\\Normal\\" + username + "\\" + date);
if (!System.IO.Directory.Exists(destination))
{
System.IO.Directory.CreateDirectory(destination);
}
htp.SaveAs(destination + "\\" + filename);
htp.InputStream.Close();
htp.InputStream.Dispose();
If i want to delete those images then am getting error.
|
|
|
|
|
I have a WPF app that gets data from a hardware device.
When the data comes in it is converted to a DataModel, then an event is raised called DataReceived. The View Model base class is subscribed to this event.
What I would like to do is have the event subscription in the base view model as an abstract class, but only have the correct implementation in the subclasses actually receive it.
See this[^]
Is this possible?
If it's not broken, fix it until it is
|
|
|
|
|
why not implement a filter event method then?
class BaseModel
{
internal virtual void OnReceive(EventModel ev)
{
if (HandleEvent(ev))
OnHandle(ev);
}
public virtual bool HandleEvent(EventModel ev) { return true;}
protected virtual void OnHandle(EventModel model) { }
}
You can even make the HandleEvent() method automatic using some generic constraint, if you so desire...
|
|
|
|
|
So it would be up to each subclass to determine if the event was handled?
If it's not broken, fix it until it is
|
|
|
|
|
|
Ok, so I modified your approach just a bit:
public abstract class BaseViewModel
{
public ViewTypes ViewType { get; protected set; }
public BaseViewModel()
{
ViewType = ViewTypes.None;
AppCore.DataReceived += AppCore_DataReceived;
}
public void AppCore_DataReceived(object sender, DataReceivedArgs args)
{
if (CanHandleDataReceived(args))
{
DataReceived(args);
}
}
protected virtual bool CanHandleDataReceived(DataReceivedArgs args)
{
return ViewType == args.ViewType;
}
protected abstract void DataReceived(DataReceivedArgs args);
}
The subclasses now only need to set the ViewType property. Then this code checks for the type and if it matches, calls the abstract DataReceived.
What do ya think?
If it's not broken, fix it until it is
|
|
|
|
|
I was thinking just that!
|
|
|
|
|
Have a .net 4.0 application that when installed on Win 7 or 10 having issues with not being able to update the config file. Where is the proper location for the app.Exe.Config file?
|
|
|
|
|
The 'proper' location for app.exe.config is in the same directory/folder as app.exe
I'm not even sure if you can have app.exe.config in a different folder (if you're using the standard App Config do-dads) - I'd have to look it up
|
|
|
|
|
The proper location is in the same folder with the .EXE, usually in a folder under Program Files.
The problem is Program Files and everything under it is ReadOnly to normal users.
You really should NOT be writing to app.config. A proper method would be to write the changeable data to another config file in a folder under CommonAppData (see Environment.GetFolderPath).
|
|
|
|
|
So what is the proper method and what elements should be stored in the app.Exe.Config? I have a client application that stores both application settings and the connection strings to connect to the database.
Where can I find best practices on this?
|
|
|
|
|
|
My question is: I want to know the index of /* and */ coming immediate before alpha2
Example:
hello world /* this is */ right way to get the index of /* track to */ alpha2 dummy text alpha dummy /* test */textalpha dummy text
Thanks in advance
|
|
|
|
|
A Regular Expression[^] is probably the simplest way:
string input = @"hello world /* this is */ right way to get the index of /* track to */ alpha2 dummy text alpha dummy /* test */textalpha dummy text";
Regex pattern = new Regex(@"\/\*[^\*\/]*\*\/\s+alpha2");
Match match = pattern.Match(input);
if (match.Success)
{
int theIndex = match.Index;
...
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks Homer,
Its good but is there any way without the regular expression as I have to search from a file and there are a lot of same keywords like alpha2. with this regular expression It will be difficult to find specific instance and its immediate before characters. Actually I have to track the keywords which are not coming in comments section. Not coming in /* */ and not started with //. comment may be of many lines. Can you please suggest the solution.
Thanks in advance.
Rohit
|
|
|
|
|
|
Imports System
Imports System.IO
Imports System.Security.Cryptography
Imports System.Text
Friend Module #=qnhMLJurfpCWeGTTrMp3zBjm4bT7W4Gu70ST3HDDMUvo=
Friend Function #=q_ppzL1ZMYuGAEacS2FNOow==(ByVal u0023u003dqoh0ULu0024aAZVl6oonbDD8nVQu003du003d As String, ByVal u0023u003dqUG3UZJJnuLYlguu0024yNB5nSAu003du003d As String) As String
Dim numArray As Byte() = Nothing
Dim numArray1 As Byte() = Nothing
Dim passwordDeriveByte As PasswordDeriveBytes = Nothing
If (u0023u003dqoh0ULu0024aAZVl6oonbDD8nVQu003du003d.Length = 0) Then
Return ""
End If
Dim bytes As Byte() = Encoding.ASCII.GetBytes("GhqBYxD5sW1Hvh7r")
If (4 <> 0) Then
numArray = bytes
Else
End If
Dim numArray2 As Byte() = Convert.FromBase64String(u0023u003dqoh0ULu0024aAZVl6oonbDD8nVQu003du003d)
If (0 = 0) Then
numArray1 = numArray2
Else
End If
Dim passwordDeriveByte1 As PasswordDeriveBytes = New PasswordDeriveBytes(u0023u003dqUG3UZJJnuLYlguu0024yNB5nSAu003du003d, Nothing)
If (0 = 0) Then
passwordDeriveByte = passwordDeriveByte1
Else
End If
Dim bytes1 As Byte() = passwordDeriveByte.GetBytes(32)
Dim rijndaelManaged As System.Security.Cryptography.RijndaelManaged = New System.Security.Cryptography.RijndaelManaged() With
{
.Mode = CipherMode.CBC
}
Dim cryptoTransform As ICryptoTransform = rijndaelManaged.CreateDecryptor(bytes1, numArray)
Dim memoryStream As System.IO.MemoryStream = New System.IO.MemoryStream(numArray1)
Dim cryptoStream As System.Security.Cryptography.CryptoStream = New System.Security.Cryptography.CryptoStream(memoryStream, cryptoTransform, CryptoStreamMode.Read)
Dim numArray3(CInt(numArray1.Length) - 1) As Byte
Dim num As Integer = cryptoStream.Read(numArray3, 0, CInt(numArray3.Length))
memoryStream.Close()
cryptoStream.Close()
Return Encoding.UTF8.GetString(numArray3, 0, num)
End Function
Friend Function #=q6As9fqtPs9VXgnilv68uIQ==(ByVal u0023u003dqV7rw1c8rt3L9lxbG3YKFwwu003du003d As String, ByVal u0023u003dqHHfPvwyiLsPiMz1KklCg8wu003du003d As String) As String
Dim numArray As Byte() = Nothing
Dim numArray1 As Byte() = Nothing
Dim passwordDeriveByte As PasswordDeriveBytes = Nothing
If (u0023u003dqV7rw1c8rt3L9lxbG3YKFwwu003du003d.Length = 0) Then
Return ""
End If
Dim bytes As Byte() = Encoding.UTF8.GetBytes("GhqBYxD5sW1Hvh7r")
If (1 <> 0) Then
numArray = bytes
Else
End If
Dim bytes1 As Byte() = Encoding.UTF8.GetBytes(u0023u003dqV7rw1c8rt3L9lxbG3YKFwwu003du003d)
If (0 = 0) Then
numArray1 = bytes1
Else
End If
Dim passwordDeriveByte1 As PasswordDeriveBytes = New PasswordDeriveBytes(u0023u003dqHHfPvwyiLsPiMz1KklCg8wu003du003d, Nothing)
If (0 = 0) Then
passwordDeriveByte = passwordDeriveByte1
Else
End If
Dim bytes2 As Byte() = passwordDeriveByte.GetBytes(32)
Dim rijndaelManaged As System.Security.Cryptography.RijndaelManaged = New System.Security.Cryptography.RijndaelManaged() With
{
.Mode = CipherMode.CBC
}
Dim cryptoTransform As ICryptoTransform = rijndaelManaged.CreateEncryptor(bytes2, numArray)
Dim memoryStream As System.IO.MemoryStream = New System.IO.MemoryStream()
Dim cryptoStream As System.Security.Cryptography.CryptoStream = New System.Security.Cryptography.CryptoStream(memoryStream, cryptoTransform, CryptoStreamMode.Write)
cryptoStream.Write(numArray1, 0, CInt(numArray1.Length))
cryptoStream.FlushFinalBlock()
Dim array As Byte() = memoryStream.ToArray()
memoryStream.Close()
cryptoStream.Close()
Return Convert.ToBase64String(array)
End Function
End Module
|
|
|
|
|
Since when does CodeProject provide a free hacker service?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|