Problème avec fonction GetPrivateProfileInt
Bonjour,
J'ai un fichier ini que je lis pour récupérer quelques paramétrage. Cependant, dans ma fonction de récupération de la valeur d'une clé, j'ai l'erreur suivante lorsque j'appel fonction GetPrivateProfileInt :
Citation:
System.AccessViolationException was unhandled by user code
Message="Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
Source="TEC_NAVWebService"
StackTrace:
at TEC_NAVWebService.Service1.GetPrivateProfileInt(String& lpApplicationName, String& lpKeyName, Int64 nDefault, String& lpFileName) at TEC_NAVWebService.Service1.GetIniParameter(String Key) in C:\WORK\PROJECTS\NEWCOM\WEB SERVICE NAV\TEC_NAVWebService\TEC_NAVWebService\Service1.asmx.vb:line 105 at TEC_NAVWebService.Service1.GetItemInfosCust(XmlDocument XItemCustInfos) in C:\WORK\PROJECTS\NEWCOM\WEB SERVICE NAV\TEC_NAVWebService\TEC_NAVWebService\Service1.asmx.vb:line 43 at WebApplication1._Default.GetItemInfos(Object sender, EventArgs e) in C:\WORK\PROJECTS\NEWCOM\WEB SERVICE NAV\WebApplication1\WebApplication1\Default.aspx.cs:line 40 at System.Web.UI.WebControls.Button.OnClick(EventArgs e) at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
InnerException:
Cette erreur ne survient pas lorsque la fonction GetPrivateProfileString est appelée !
Voici le code de ma fonction :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| Private Function GetIniParameter(ByVal Key As String) As String
Dim projDir As String = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase)
Dim filePath As String = Mid(projDir, 7, Len(projDir) - 6) + "\TEC_WebServ.ini"
Dim StrBuild As New System.Text.StringBuilder(32768)
Dim IntValue As Integer
Dim StrValue As String
If Key = "MSMQReceiverTimeSpanSec" Then
IntValue = GetPrivateProfileInt("Setup", Key, -1, filePath)
StrValue = IntValue.ToString
Else
GetPrivateProfileString("Setup", Key, "", StrBuild, 32768, filePath)
StrValue = StrBuild.ToString
End If
Return StrValue |
Quelqu'un a-t-il une idée de quoi ça pourrait venir ? Je cherche mais ne trouve rien et suis vraiment bloqué par ce problème.
Merci d'avance de votre aide.