 |
 |
Index ‹ DotNet ‹ Visual C#.Net
|
- Previous
- 1
- Dotnet >> cannot repair, add or unsinstall dotnetHi all
i'm new here, i have a big problem during the installation of Ms Visual
Studio .Net
when i want to repair,uninstall or add a components it works but failed at
the end
the error log say :
Visual Studio .NET Professional - French: [2] ERROR_FILE_NOT_FOUND returned
in CRootComponent::Install; could not find file:
C:\WINNT\Installer\202ee613.msiI don't know what to do, i've tried to
reinstall all the components needed but it stills fails :(do you have any
idea or clue ?Thanks fo allBen
- 2
- 3
- Dotnet >> opening a frameset in an IFrameHello,
I've written a C# web application.
I'm using frameset that contains 3 frames.
when i try to open this frameset in an iframe and i try to reference other
frames from a different frame, i get an error, for example:
"'top.frames,tabs.location' is null or not an object"
how can i solve this problem?
Thanks,
Dana
- 4
- 5
- ADO >> problem executing sproc from ASP(ADO).NETcan anyone tell me why the following will not work or how to fix it. This
works fine for executing sprocs with no parms but fails (always returns -1)
when executing with parms.
from webform:
Private Sub Find_Button_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Find_Button.Click
Dim resultDS As DataSet
Dim retVal As Integer
Dim parmArray(2) As SqlClient.SqlParameter
parmArray(0) = New SqlClient.SqlParameter("@SEARCHTYPE",
SqlDbType.VarChar)
parmArray(0).Value = SearchType.SelectedValue
parmArray(1) = New SqlClient.SqlParameter("@SEARCHTERM",
SqlDbType.VarChar)
parmArray(1).Value = SearchTerm.Text
parmArray(2) = New SqlClient.SqlParameter("@INC_CLOSED",
SqlDbType.VarChar)
parmArray(2).Value = UCase(IncClosed.Checked.ToString)
Call ExecSP("PROC_MASTER_SEARCH", retVal, parmArray, resultDS)
DataGrid_Results.DataSource = resultDS
DataGrid_Results.DataBind()
End Sub
from db access module (adapted from Using Visual Basic.Net by Siler and
Spotts)
Private Sub PopulateCommandParms(ByVal parmArray() As SqlParameter, ByRef
cmd As SqlCommand)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'adds each parameter to the command object
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim i As Integer
For i = LBound(parmArray) To UBound(parmArray)
cmd.Parameters.Add(parmArray(i))
Next
End Sub
Private Sub PopulateOutputParms(ByVal cmd As SqlCommand, ByRef
parmArray() As SqlParameter)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'copies output parameter values back into the array
'assumes parameter array is already populated
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim i As Integer
For i = LBound(parmArray) To UBound(parmArray)
If parmArray(i).Direction = ParameterDirection.Output Then
parmArray(i).Value =
cmd.Parameters(parmArray(i).ParameterName).Value
End If
Next
End Sub
Public Sub ExecSP(ByVal procName As String, ByRef retVal As Integer, _
Optional ByRef parmArray() As SqlParameter = Nothing, _
Optional ByRef resultDS As DataSet = Nothing)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'executes stored procedures returning output parameters or filling a
dataset
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim dbConn As SqlConnection
Dim dbCmd As SqlCommand
Dim dbAdp As SqlDataAdapter
'open the connection
dbConn = New SqlConnection
dbConn.ConnectionString = GetConnectionString()
dbConn.Open()
'create the command object
dbCmd = New SqlCommand
dbCmd.CommandText = procName
dbCmd.CommandType = CommandType.StoredProcedure
dbCmd.Connection = dbConn
'add parameters to the connection object if they exist
If Not (parmArray Is Nothing) Then
Call PopulateCommandParms(parmArray, dbCmd)
End If
'execute the command
If resultDS Is Nothing Then
retVal = dbCmd.ExecuteNonQuery
Else
resultDS = New DataSet
dbAdp = New SqlDataAdapter
dbAdp.SelectCommand = dbCmd
retVal = dbAdp.Fill(resultDS)
End If
'close the connection
dbConn.Close()
'populate output parameters
If Not (parmArray Is Nothing) Then
Call PopulateOutputParms(dbCmd, parmArray)
End If
End Sub
- 6
- Microsoft Project >> Creating Custom LegendsI'm trying to create custom legends for my schedules - I can create them in
Page Setup but they show up on the print out. Please let me know if you have
any tips on creating legends.
Thanks for your help
- 7
- Net Framework >> .Net Framework 1.1 SP1 brok COM+ componentsAfter installing SP1 for the .Net framework 1.1 on a Windows 2000 server, all
the COM+ components ceased to be accessible from my VB6 applications. The
only error that was received was that it could not load the dll. I ended up
deleting the components and reapplying them with regsvcs.
Fortunately, we only have a few .Net COM+ components being accessed by VB6.
Has anyone else seen this?
- 8
- Dotnet >> Windows service notification iconHi,
I made a 'windows services' which works well. When I added a notificaton
icon, the icon apeared in the tray bar but when I clicked it, no events came
into my service. (I did allowed the service to intercat with the desktop).
Can you tell me why I can't receive the events?
Thank you
--
Rafi
Israel
- 9
- Visual C#.Net >> Installing a font using C#Hi
I was wondering if anyone knows how to install a system font using C#?
I know it doesn´t do the trick to simply copy the font to the font
directory, it just doesn´t become active.
Any ideas?
/Johan
- 10
- Visual C#.Net >> Unable to write data to the transport connection: An established connectionHello,
I'm trying to upload a file programatically and occasionally I get the
following error message.
Unable to write data to the transport connection: An established connection
was aborted by the software in your host machine.
Stack Trace
at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32 offset, Int32
size)
at System.Net.FtpDataStream.Write(Byte[] buffer, Int32 offset, Int32
size)
at HSMoveFiles.FTPClient.Upload(FileInfo fi, String targetFilename) in
C:\DOTNET\HSMoveFiles\FTPClient.cs:line 177
The source code for FTPClient.cs came from the following URL
http://www.codeproject.com/vb/net/FtpClient.asp
The exception is been thrown when trying to write the Stream.
rs.Write(content, 0, dataRead)
Has anyone got any Idea why this might happen and how to solve it?
Exception is caught at line number 185. Throw ex;.
Here is the source code. See line number 177.
using System.Collections.Generic;
using System;
using System.Net;
using System.IO;
using System.Runtime.Remoting.Lifetime;
using System.Text.RegularExpressions;
namespace HSMoveFiles
{
#region "FTP client class"
/// <summary>
/// A wrapper class for .NET 2.0 FTP
/// </summary>
/// <remarks>
/// This class does not hold open an FTP connection but
/// instead is stateless: for each FTP request it
/// connects, performs the request and disconnects.
/// </remarks>
public class FTPClient
{
#region "CONSTRUCTORS"
/// <summary>
/// Blank constructor
/// </summary>
/// <remarks>Hostname, username and password must be set manually</remarks>
public FTPClient()
{
}
/// <summary>
/// Constructor just taking the hostname
/// </summary>
/// <param name="Hostname">in either ftp://ftp.host.com or ftp.host.com
form</param>
/// <remarks></remarks>
public FTPClient(string Hostname)
{
_hostname = Hostname;
}
/// <summary>
/// Constructor taking hostname, username and password
/// </summary>
/// <param name="Hostname">in either ftp://ftp.host.com or ftp.host.com
form</param>
/// <param name="Username">Leave blank to use 'anonymous' but set password
to your email</param>
/// <param name="Password"></param>
/// <remarks></remarks>
public FTPClient(string Hostname, string Username, string Password)
{
_hostname = Hostname;
_username = Username;
_password = Password;
}
#endregion
#region "Directory functions"
/// <summary>
/// Return a simple directory listing
/// </summary>
/// <param name="directory">Directory to list, e.g. /pub</param>
/// <returns>A list of filenames and directories as a List(of
String)</returns>
/// <remarks>For a detailed directory listing, use
ListDirectoryDetail</remarks>
public List<string> ListDirectory(string directory)
{
//return a simple list of filenames in directory
System.Net.FtpWebRequest ftp = GetRequest(GetDirectory(directory));
//Set request to do simple list
ftp.Method = System.Net.WebRequestMethods.Ftp.ListDirectory;
string str = GetStringResponse(ftp);
//replace CRLF to CR, remove last instance
str = str.Replace("\r\n", "\r").TrimEnd('\r');
//split the string into a list
List<string> result = new List<string>();
result.AddRange(str.Split('\r'));
return result;
}
/// <summary>
/// Return a detailed directory listing
/// </summary>
/// <param name="directory">Directory to list, e.g. /pub/etc</param>
/// <returns>An FTPDirectory object</returns>
public FTPdirectory ListDirectoryDetail(string directory)
{
System.Net.FtpWebRequest ftp = GetRequest(GetDirectory(directory));
//Set request to do simple list
ftp.Method = System.Net.WebRequestMethods.Ftp.ListDirectoryDetails;
string str = GetStringResponse(ftp);
//replace CRLF to CR, remove last instance
str = str.Replace("\r\n", "\r").TrimEnd('\r');
//split the string into a list
return new FTPdirectory(str, _lastDirectory);
}
#endregion
#region "Upload: File transfer TO ftp server"
/// <summary>
/// Copy a local file to the FTP server
/// </summary>
/// <param name="localFilename">Full path of the local file</param>
/// <param name="targetFilename">Target filename, if required</param>
/// <returns></returns>
/// <remarks>If the target filename is blank, the source filename is used
/// (assumes current directory). Otherwise use a filename to specify a name
/// or a full path and filename if required.</remarks>
public bool Upload(string localFilename, string targetFilename)
{
//1. check source
if (!File.Exists(localFilename))
{
throw (new ApplicationException("File " + localFilename + " not found"));
}
//copy to FI
FileInfo fi = new FileInfo(localFilename);
return Upload(fi, targetFilename);
}
/// <summary>
/// Upload a local file to the FTP server
/// </summary>
/// <param name="fi">Source file</param>
/// <param name="targetFilename">Target filename (optional)</param>
/// <returns></returns>
public bool Upload(FileInfo fi, string targetFilename)
{
//copy the file specified to target file: target file can be full path or
just filename (uses current dir)
//1. check target
string target;
if (targetFilename.Trim() == "")
{
//Blank target: use source filename & current dir
target = this.CurrentDirectory + fi.Name;
}
else if (targetFilename.Contains("/"))
{
//If contains / treat as a full path
target = AdjustDir(targetFilename);
}
else
{
//otherwise treat as filename only, use current directory
target = CurrentDirectory + targetFilename;
}
string URI = Hostname + target;
//perform copy
System.Net.FtpWebRequest ftp = GetRequest(URI);
//Set request to upload a file in binary
ftp.Method = System.Net.WebRequestMethods.Ftp.UploadFile;
ftp.UseBinary = true;
//Notify FTP of the expected size
ftp.ContentLength = fi.Length;
//create byte array to store: ensure at least 1 byte!
int BufferSize = 2048;
byte[] content = new byte[BufferSize - 1 + 1];
int dataRead;
//open file for reading
using (FileStream fs = fi.OpenRead())
{
try
{
//open request to send
using (Stream rs = ftp.GetRequestStream())
{
do
{
dataRead = fs.Read(content, 0, BufferSize);
rs.Write(content, 0, dataRead);
} while (!(dataRead < BufferSize));
rs.Close();
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
//ensure file closed
fs.Close();
ftp = null;
}
}
return true;
}
#endregion
#region "Download: File transfer FROM ftp server"
/// <summary>
/// Copy a file from FTP server to local
/// </summary>
/// <param name="sourceFilename">Target filename, if required</param>
/// <param name="localFilename">Full path of the local file</param>
/// <returns></returns>
/// <remarks>Target can be blank (use same filename), or just a filename
/// (assumes current directory) or a full path and filename</remarks>
public bool Download(string sourceFilename, string localFilename, bool
PermitOverwrite)
{
//2. determine target file
FileInfo fi = new FileInfo(localFilename);
return this.Download(sourceFilename, fi, PermitOverwrite);
}
//Version taking an FtpFileInfo
public bool Download(FTPfileInfo file, string localFilename, bool
PermitOverwrite)
{
return this.Download(file.FullName, localFilename, PermitOverwrite);
}
//Another version taking FtpFileInfo and FileInfo
public bool Download(FTPfileInfo file, FileInfo localFI, bool
PermitOverwrite)
{
return this.Download(file.FullName, localFI, PermitOverwrite);
}
//Version taking string/FileInfo
public bool Download(string sourceFilename, FileInfo targetFI, bool
PermitOverwrite)
{
//1. check target
if (targetFI.Exists && !(PermitOverwrite))
{
throw (new ApplicationException("Target file already exists"));
}
//2. check source
string target;
if (sourceFilename.Trim() == "")
{
throw (new ApplicationException("File not specified"));
}
else if (sourceFilename.Contains("/"))
{
//treat as a full path
target = AdjustDir(sourceFilename);
}
else
{
//treat as filename only, use current directory
target = CurrentDirectory + sourceFilename;
}
string URI = Hostname + target;
//3. perform copy
System.Net.FtpWebRequest ftp = GetRequest(URI);
//Set request to download a file in binary mode
ftp.Method = System.Net.WebRequestMethods.Ftp.DownloadFile;
ftp.UseBinary = true;
//open request and get response stream
using (FtpWebResponse response = (FtpWebResponse)ftp.GetResponse())
{
using (Stream responseStream = response.GetResponseStream())
{
//loop to read & write to file
using (FileStream fs = targetFI.OpenWrite())
{
try
{
byte[] buffer = new byte[2048];
int read = 0;
do
{
read = responseStream.Read(buffer, 0, buffer.Length);
fs.Write(buffer, 0, read);
} while (!(read == 0));
responseStream.Close();
fs.Flush();
fs.Close();
}
catch (Exception)
{
//catch error and delete file only partially downloaded
fs.Close();
//delete target file as it's incomplete
targetFI.Delete();
throw;
}
}
responseStream.Close();
}
response.Close();
}
return true;
}
#endregion
#region "Other functions: Delete rename etc."
/// <summary>
/// Delete remote file
/// </summary>
/// <param name="filename">filename or full path</param>
/// <returns></returns>
/// <remarks></remarks>
public bool FtpDelete(string filename)
{
//Determine if file or full path
string URI = this.Hostname + GetFullPath(filename);
System.Net.FtpWebRequest ftp = GetRequest(URI);
//Set request to delete
ftp.Method = System.Net.WebRequestMethods.Ftp.DeleteFile;
try
{
//get response but ignore it
string str = GetStringResponse(ftp);
}
catch (Exception)
{
return false;
}
return true;
}
/// <summary>
/// Determine if file exists on remote FTP site
/// </summary>
/// <param name="filename">Filename (for current dir) or full path</param>
/// <returns></returns>
/// <remarks>Note this only works for files</remarks>
public bool FtpFileExists(string filename)
{
//Try to obtain filesize: if we get error msg containing "550"
//the file does not exist
try
{
long size = GetFileSize(filename);
return true;
}
catch (Exception ex)
{
//only handle expected not-found exception
if (ex is System.Net.WebException)
{
//file does not exist/no rights error = 550
if (ex.Message.Contains("550"))
{
//clear
return false;
}
else
{
throw;
}
}
else
{
throw;
}
}
}
/// <summary>
/// Determine size of remote file
/// </summary>
/// <param name="filename"></param>
/// <returns></returns>
/// <remarks>Throws an exception if file does not exist</remarks>
public long GetFileSize(string filename)
{
string path;
if (filename.Contains("/"))
{
path = AdjustDir(filename);
}
else
{
path = this.CurrentDirectory + filename;
}
string URI = this.Hostname + path;
System.Net.FtpWebRequest ftp = GetRequest(URI);
//Try to get info on file/dir?
ftp.Method = System.Net.WebRequestMethods.Ftp.GetFileSize;
string tmp = this.GetStringResponse(ftp);
return GetSize(ftp);
}
public bool FtpRename(string sourceFilename, string newName)
{
//Does file exist?
string source = GetFullPath(sourceFilename);
if (!FtpFileExists(source))
{
throw (new FileNotFoundException("File " + source + " not found"));
}
//build target name, ensure it does not exist
string target = GetFullPath(newName);
if (target == source)
{
throw (new ApplicationException("Source and target are the same"));
}
else if (FtpFileExists(target))
{
throw (new ApplicationException("Target file " + target + " already
exists"));
}
//perform rename
string URI = this.Hostname + source;
System.Net.FtpWebRequest ftp = GetRequest(URI);
//Set request to delete
ftp.Method = System.Net.WebRequestMethods.Ftp.Rename;
ftp.RenameTo = target;
try
{
//get response but ignore it
string str = GetStringResponse(ftp);
}
catch (Exception)
{
return false;
}
return true;
}
public bool FtpCreateDirectory(string dirpath)
{
//perform create
string URI = this.Hostname + AdjustDir(dirpath);
System.Net.FtpWebRequest ftp = GetRequest(URI);
//Set request to MkDir
ftp.Method = System.Net.WebRequestMethods.Ftp.MakeDirectory;
try
{
//get response but ignore it
string str = GetStringResponse(ftp);
}
catch (Exception)
{
return false;
}
return true;
}
public bool FtpDeleteDirectory(string dirpath)
{
//perform remove
string URI = this.Hostname + AdjustDir(dirpath);
System.Net.FtpWebRequest ftp = GetRequest(URI);
//Set request to RmDir
ftp.Method = System.Net.WebRequestMethods.Ftp.RemoveDirectory;
try
{
//get response but ignore it
string str = GetStringResponse(ftp);
}
catch (Exception)
{
return false;
}
return true;
}
#endregion
#region "private supporting fns"
//Get the basic FtpWebRequest object with the
//common settings and security
private FtpWebRequest GetRequest(string URI)
{
//create request
FtpWebRequest result = (FtpWebRequest)FtpWebRequest.Create(URI);
//Set the login details
result.Credentials = GetCredentials();
//Do not keep alive (stateless mode)
result.KeepAlive = true;
return result;
}
/// <summary>
/// Get the credentials from username/password
/// </summary>
private System.Net.ICredentials GetCredentials()
{
return new System.Net.NetworkCredential(Username, Password);
}
/// <summary>
/// returns a full path using CurrentDirectory for a relative file reference
/// </summary>
private string GetFullPath(string file)
{
if (file.Contains("/"))
{
return AdjustDir(file);
}
else
{
return this.CurrentDirectory + file;
}
}
/// <summary>
/// Amend an FTP path so that it always starts with /
/// </summary>
/// <param name="path">Path to adjust</param>
/// <returns></returns>
/// <remarks></remarks>
private string AdjustDir(string path)
{
return ((path.StartsWith("/")) ? "" : "/").ToString() + path;
}
private string GetDirectory(string directory)
{
string URI;
if (directory == "")
{
//build from current
URI = Hostname + this.CurrentDirectory;
_lastDirectory = this.CurrentDirectory;
}
else
{
if (!directory.StartsWith("/"))
{
throw (new ApplicationException("Directory should start with /"));
}
URI = this.Hostname + directory;
_lastDirectory = directory;
}
return URI;
}
//stores last retrieved/set directory
private string _lastDirectory = "";
/// <summary>
/// Obtains a response stream as a string
/// </summary>
/// <param name="ftp">current FTP request</param>
/// <returns>String containing response</returns>
/// <remarks>FTP servers typically return strings with CR and
/// not CRLF. Use respons.Replace(vbCR, vbCRLF) to convert
/// to an MSDOS string</remarks>
private string GetStringResponse(FtpWebRequest ftp)
{
//Get the result, streaming to a string
string result = "";
using (FtpWebResponse response = (FtpWebResponse)ftp.GetResponse())
{
long size = response.ContentLength;
using (Stream datastream = response.GetResponseStream())
{
using (StreamReader sr = new StreamReader(datastream))
{
result = sr.ReadToEnd();
sr.Close();
}
datastream.Close();
}
response.Close();
}
return result;
}
/// <summary>
/// Gets the size of an FTP request
/// </summary>
/// <param name="ftp"></param>
/// <returns></returns>
/// <remarks></remarks>
private long GetSize(FtpWebRequest ftp)
{
long size;
using (FtpWebResponse response = (FtpWebResponse)ftp.GetResponse())
{
size = response.ContentLength;
response.Close();
}
return size;
}
#endregion
#region "Properties"
private string _hostname;
/// <summary>
/// Hostname
/// </summary>
/// <value></value>
/// <remarks>Hostname can be in either the full URL format
/// ftp://ftp.myhost.com or just ftp.myhost.com
/// </remarks>
public string Hostname
{
get
{
if (_hostname.StartsWith("ftp://"))
{
return _hostname;
}
else
{
return "ftp://" + _hostname;
}
}
set
{
_hostname = value;
}
}
private string _username;
/// <summary>
/// Username property
/// </summary>
/// <value></value>
/// <remarks>Can be left blank, in which case 'anonymous' is
returned</remarks>
public string Username
{
get
{
return (_username == "" ? "anonymous" : _username);
}
set
{
_username = value;
}
}
private string _password;
public string Password
{
get
{
return _password;
}
set
{
_password = value;
}
}
/// <summary>
/// The CurrentDirectory value
/// </summary>
/// <remarks>Defaults to the root '/'</remarks>
private string _currentDirectory = "/";
public string CurrentDirectory
{
get
{
//return directory, ensure it ends with /
return _currentDirectory + ((_currentDirectory.EndsWith("/")) ? "" :
"/").ToString();
}
set
{
if (!value.StartsWith("/"))
{
throw (new ApplicationException("Directory should start with /"));
}
_currentDirectory = value;
}
}
#endregion
}
#endregion
#region "FTP file info class"
/// <summary>
/// Represents a file or directory entry from an FTP listing
/// </summary>
/// <remarks>
/// This class is used to parse the results from a detailed
/// directory list from FTP. It supports most formats of
/// </remarks>
public class FTPfileInfo
{
//Stores extended info about FTP file
#region "Properties"
public string FullName
{
get
{
return Path + Filename;
}
}
public string Filename
{
get
{
return _filename;
}
}
public string Path
{
get
{
return _path;
}
}
public DirectoryEntryTypes FileType
{
get
{
return _fileType;
}
}
public long Size
{
get
{
return _size;
}
}
public DateTime FileDateTime
{
get
{
return _fileDateTime;
}
}
public string Permission
{
get
{
return _permission;
}
}
public string Extension
{
get
{
int i = this.Filename.LastIndexOf(".");
if (i >= 0 && i < (this.Filename.Length - 1))
{
return this.Filename.Substring(i + 1);
}
else
{
return "";
}
}
}
public string NameOnly
{
get
{
int i = this.Filename.LastIndexOf(".");
if (i > 0)
{
return this.Filename.Substring(0, i);
}
else
{
return this.Filename;
}
}
}
private string _filename;
private string _path;
private DirectoryEntryTypes _fileType;
private long _size;
private DateTime _fileDateTime;
private string _permission;
#endregion
/// <summary>
/// Identifies entry as either File or Directory
/// </summary>
public enum DirectoryEntryTypes
{
File,
Directory
}
/// <summary>
/// Constructor taking a directory listing line and path
/// </summary>
/// <param name="line">The line returned from the detailed directory
list</param>
/// <param name="path">Path of the directory</param>
/// <remarks></remarks>
public FTPfileInfo(string line, string path)
{
//parse line
Match m = GetMatchingRegex(line);
if (m == null)
{
//failed
throw (new ApplicationException("Unable to parse line: " + line));
}
else
{
_filename = m.Groups["name"].Value;
_path = path;
Int64.TryParse(m.Groups["size"].Value, out _size);
//_size = System.Convert.ToInt32(m.Groups["size"].Value);
_permission = m.Groups["permission"].Value;
string _dir = m.Groups["dir"].Value;
if (_dir != "" && _dir != "-")
{
_fileType = DirectoryEntryTypes.Directory;
}
else
{
_fileType = DirectoryEntryTypes.File;
}
try
{
_fileDateTime = DateTime.Parse(m.Groups["timestamp"].Value);
}
catch (Exception)
{
_fileDateTime = Convert.ToDateTime(null);
}
}
}
private Match GetMatchingRegex(string line)
{
Regex rx;
Match m;
for (int i = 0; i <= _ParseFormats.Length - 1; i++)
{
rx = new Regex(_ParseFormats[i]);
m = rx.Match(line);
if (m.Success)
{
return m;
}
}
return null;
}
#region "Regular expressions for parsing LIST results"
/// <summary>
/// List of REGEX formats for different FTP server listing formats
/// </summary>
/// <remarks>
/// The first three are various UNIX/LINUX formats, fourth is for MS FTP
/// in detailed mode and the last for MS FTP in 'DOS' mode.
/// I wish VB.NET had support for Const arrays like C# but there you go
/// </remarks>
private static string[] _ParseFormats = new string[] {
"(?<dir>[\\-d])(?<permission>([\\-r][\\-w][\\-xs]){3})\\s+\\d+\\s+\\w+\\s+\\w+\\s+(?<size>\\d+)\\s+(?<timestamp>\\w+\\s+\\d+\\s+\\d{4})\\s+(?<name>.+)",
"(?<dir>[\\-d])(?<permission>([\\-r][\\-w][\\-xs]){3})\\s+\\d+\\s+\\d+\\s+(?<size>\\d+)\\s+(?<timestamp>\\w+\\s+\\d+\\s+\\d{4})\\s+(?<name>.+)",
"(?<dir>[\\-d])(?<permission>([\\-r][\\-w][\\-xs]){3})\\s+\\d+\\s+\\d+\\s+(?<size>\\d+)\\s+(?<timestamp>\\w+\\s+\\d+\\s+\\d{1,2}:\\d{2})\\s+(?<name>.+)",
"(?<dir>[\\-d])(?<permission>([\\-r][\\-w][\\-xs]){3})\\s+\\d+\\s+\\w+\\s+\\w+\\s+(?<size>\\d+)\\s+(?<timestamp>\\w+\\s+\\d+\\s+\\d{1,2}:\\d{2})\\s+(?<name>.+)",
"(?<dir>[\\-d])(?<permission>([\\-r][\\-w][\\-xs]){3})(\\s+)(?<size>(\\d+))(\\s+)(?<ctbit>(\\w+\\s\\w+))(\\s+)(?<size2>(\\d+))\\s+(?<timestamp>\\w+\\s+\\d+\\s+\\d{2}:\\d{2})\\s+(?<name>.+)",
"(?<timestamp>\\d{2}\\-\\d{2}\\-\\d{2}\\s+\\d{2}:\\d{2}[Aa|Pp][mM])\\s+(?<dir>\\<\\w+\\>){0,1}(?<size>\\d+){0,1}\\s+(?<name>.+)"
};
#endregion
}
#endregion
#region "FTP Directory class"
/// <summary>
/// Stores a list of files and directories from an FTP result
/// </summary>
/// <remarks></remarks>
public class FTPdirectory : List<FTPfileInfo>
{
public FTPdirectory()
{
//creates a blank directory listing
}
/// <summary>
/// Constructor: create list from a (detailed) directory string
/// </summary>
/// <param name="dir">directory listing string</param>
/// <param name="path"></param>
/// <remarks></remarks>
public FTPdirectory(string dir, string path)
{
foreach (string line in dir.Replace("\n",
"").Split(System.Convert.ToChar('\r')))
{
//parse
if (line != "")
{
this.Add(new FTPfileInfo(line, path));
}
}
}
/// <summary>
/// Filter out only files from directory listing
/// </summary>
/// <param name="ext">optional file extension filter</param>
/// <returns>FTPdirectory listing</returns>
public FTPdirectory GetFiles(string ext)
{
return this.GetFileOrDir(FTPfileInfo.DirectoryEntryTypes.File, ext);
}
/// <summary>
/// Returns a list of only subdirectories
/// </summary>
/// <returns>FTPDirectory list</returns>
/// <remarks></remarks>
public FTPdirectory GetDirectories()
{
return this.GetFileOrDir(FTPfileInfo.DirectoryEntryTypes.Directory, "");
}
//internal: share use function for GetDirectories/Files
private FTPdirectory GetFileOrDir(FTPfileInfo.DirectoryEntryTypes type,
string ext)
{
FTPdirectory result = new FTPdirectory();
foreach (FTPfileInfo fi in this)
{
if (fi.FileType == type)
{
if (ext == "")
{
result.Add(fi);
}
else if (ext == fi.Extension)
{
result.Add(fi);
}
}
}
return result;
}
public bool FileExists(string filename)
{
foreach (FTPfileInfo ftpfile in this)
{
if (ftpfile.Filename == filename)
{
return true;
}
}
return false;
}
private const char slash = '/';
public static string GetParentDirectory(string dir)
{
string tmp = dir.TrimEnd(slash);
int i = tmp.LastIndexOf(slash);
if (i > 0)
{
return tmp.Substring(0, i - 1);
}
else
{
throw (new ApplicationException("No parent for root"));
}
}
}
#endregion
}
- 11
- Winforms >> Access and winformHello,
I have in my application a folder "/data" where I store my .mdb.
I create a connection in my winforms (app.config)
The problem it is that when I déploy my application, the program turns
over in my developpement folder to seek the .mdb and not in
"\programFiles\myApplication\data\..."
Help
--
Ceci est une signature automatique de MesNews.
Site : http://mesnews.no-ip.com
- 12
- Microsoft Project >> Dragging Finish DateIn a Gantt view of my project (MSP2000), when I try to drag the Finish
date of a task, the whole task moves instead of increasing the
Duration. This happens for any task I try to change.
If I create a new task, it behaves the same until I set the Constraint
Type to As Soon As Possible. The task Start date automatically
changes to the Project Start date. Only then I can drag the finish
date to extend the duration.
In a new project file, I can drag the Finish Date as per design.
Help?
Fred
- 13
- Dotnet >> Intelli-Sense How do I FIX???Anyone here having problems with intellesense just stopping?
Sometimes after compiling and running a program when I go back to the editor
and start typing all of my syntax highlighting dissapears. All of my text
goes black like a regular text document. If I rebuild the project or
projects the syntax highlighting shows up again.
Also when the text goes black all of my intelli-sense quits working as well
or only shows main methods and does not drill down to the specific methods
it should.
If I continue to program I have to type everything without intellesense and
when I do this no syntax formatting happens including brace placement etc.
Also when it is acting like this if I were to make a mistake and try doing
an undo I get an error and nothing is undone. It is like visual studio
totally loses track of everything.
Another thing I have noticed is that some of my project dates do not update
either. When I first go into visual studio it shows the projects and when
they were last updated. Some of the projects do not update the date of
when they were last worked on even though I work on them quite a bit.
In order to solve the problem temporarly I have to exit out of visual studio
and reload the project. Help this is getting very very anoying!!!!
- 14
- Net Framework >> Using a POP3 ServerHi
I want to access mails through a POP3 Server
I have some simple code taht connects, listens etc. Does anyone know if I can...
- Create inboxe
- Create folders in inboxe
- Move e-mail from one folder to the othe
- Read e-mail and manipulate attachment
....through POP3
- 15
- Dotnet >> Process CPU usage jumps to 100% without any reason?I am working on an application in c# that runs in the background.
All it does is monitor a value from a performance counter using a timer. It then draws these values in a chart
Now, this application works for a long time, sometimes even days. But sometimes it just freezes and the CPU usag
spikes to 100% for that process. I really don't understand why, and there seems to be no actual event that trigger
this. It looks like this problem occures more when I am using more CPU power during a long period of tim
(f.e. when compressing something). But even then, sometimes the program freezes and sometimes it keeps running
smooth at 0-2% usage..
Is there anyone that can give me an idea on how to solve this problem
I thank you for your time
Kind regards
Kevin Chabot
|
| Author |
Message |
Kelly06

|
Posted: Fri Sep 23 03:53:22 CDT 2005 |
Top |
Visual C#.Net >> Postfix increment
Hello!
I have found an interesting thing with postfix operator ++.
What should contain the variable i after exceution the following code:
int i = 5;
i = i++;
In VC++ 7.1 and VC++ 2005 beta 2 the variable i contains 6.
But in C# 7.1 and C# 2005 beta 2 the variable i contains 5.
Is it behaviour correct? Can anyone explain what is the correct result?
Best regards,
Oleg.
DotNet75
|
| |
|
| |
 |
Andrew

|
Posted: Fri Sep 23 03:53:22 CDT 2005 |
Top |
Visual C#.Net >> Postfix increment
Hello
Hmmm, it looks really strange. I've tested it on C++ and C# (VS 2003) and
got different result.
I was expecting to get 6 in C#, but gave me 5 !
So, it looks like it we have the next algorithm:
t = i; // some temp variable or register
i++; // here we get i=6;
i=t; // here we get back i=5
Very strange !!!
--
With best regards,
Andrew
http://www.codeproject.com/script/profile/whos_who.asp?id=1181072
"Oleg Kharitonov" <EMail@HideDomain.com> wrote in message
news:EMail@HideDomain.com...
> Hello!
>
> I have found an interesting thing with postfix operator ++.
>
> What should contain the variable i after exceution the following code:
>
> int i = 5;
> i = i++;
>
> In VC++ 7.1 and VC++ 2005 beta 2 the variable i contains 6.
> But in C# 7.1 and C# 2005 beta 2 the variable i contains 5.
>
> Is it behaviour correct? Can anyone explain what is the correct result?
>
> Best regards,
> Oleg.
>
|
| |
|
| |
 |
Tasos

|
Posted: Fri Sep 23 03:58:09 CDT 2005 |
Top |
Visual C#.Net >> Postfix increment
Interesting remark :)
But I have a question on your remark ... VC++ with managed or unmanaged
code ? I can speculate on the unmanaged situation ...
|
| |
|
| |
 |
Christof

|
Posted: Fri Sep 23 04:11:38 CDT 2005 |
Top |
Visual C#.Net >> Postfix increment
"Oleg Kharitonov" <EMail@HideDomain.com> schrieb im Newsbeitrag
news:EMail@HideDomain.com...
> Hello!
>
> I have found an interesting thing with postfix operator ++.
>
> What should contain the variable i after exceution the following code:
>
> int i = 5;
> i = i++;
>
> In VC++ 7.1 and VC++ 2005 beta 2 the variable i contains 6.
> But in C# 7.1 and C# 2005 beta 2 the variable i contains 5.
>
> Is it behaviour correct? Can anyone explain what is the correct result?
>
> Best regards,
> Oleg.
The behavior of C# is correct, the behavior of C++ is incorrect.
From C++ reference:
It is important to note that a postfix increment or decrement expression
evaluates to the value of the expression prior to application of the
respective operator.
From C# reference about postfix increment:
The result of the operation is the value of the operand before it has been
incremented.
So the return value of i++ in the example is 5 not 6.
|
| |
|
| |
 |
lukasz_sw

|
Posted: Fri Sep 23 04:15:12 CDT 2005 |
Top |
Visual C#.Net >> Postfix increment
Tasos Vogiatzoglou wrote:
> Interesting remark :)
>
> But I have a question on your remark ... VC++ with managed or unmanaged
> code ? I can speculate on the unmanaged situation ...
>
I've checked - on both...
£ukasz
|
| |
|
| |
 |
Andrew

|
Posted: Fri Sep 23 04:16:32 CDT 2005 |
Top |
Visual C#.Net >> Postfix increment
Here is IL code produced from C# version of that interesting code.
So, we can see, that out "i" variable receives value of 6, but then again a
value of 5.
IL_0000: ldc.i4.5
IL_0001: stloc.0
IL_0002: ldloc.0
IL_0003: dup
IL_0004: ldc.i4.1
IL_0005: add
IL_0006: stloc.0
IL_0007: stloc.0
--
With best regards,
Andrew
http://www.codeproject.com/script/profile/whos_who.asp?id=1181072
"Oleg Kharitonov" <EMail@HideDomain.com> wrote in message
news:EMail@HideDomain.com...
> Hello!
>
> I have found an interesting thing with postfix operator ++.
>
> What should contain the variable i after exceution the following code:
>
> int i = 5;
> i = i++;
>
> In VC++ 7.1 and VC++ 2005 beta 2 the variable i contains 6.
> But in C# 7.1 and C# 2005 beta 2 the variable i contains 5.
>
> Is it behaviour correct? Can anyone explain what is the correct result?
>
> Best regards,
> Oleg.
>
|
| |
|
| |
 |
Tasos

|
Posted: Fri Sep 23 04:26:42 CDT 2005 |
Top |
Visual C#.Net >> Postfix increment
The postfix operator on C++ is evaluated after the expression is
evaluated (thus first we have i=5 and then i++) .
But as = and ++ are operators themselves I conjecture that there is a
precedence issue with ++ over =. Thus 5++ is evaluated first.
I checked the C++ Specification and ++ has higher priority than = ...
C# returns the appropriate result.
I thought that there might be a different implementation between
managed/unmanaged C++ implementation but there seems to be no rational
reason for that :)
What do you think about the precedence issue ?
|
| |
|
| |
 |
Oleg

|
Posted: Fri Sep 23 05:50:37 CDT 2005 |
Top |
Visual C#.Net >> Postfix increment
>> What should contain the variable i after exceution the following code:
>>
>> int i = 5;
>> i = i++;
>>
> The behavior of C# is correct, the behavior of C++ is incorrect.
> From C++ reference:
> It is important to note that a postfix increment or decrement expression
> evaluates to the value of the expression prior to application of the
> respective operator.
Thank you, Christof. I finally understood how this code should be executed:
1. Evaluating the value of "i++". Result is 5 becuse this is postfix ++.
2. Operator ++ has precedence over =, so i is being incrementing. Now i ==
6,
but _the result of right hand expression_ == 5.
3. i is assigning the result of right hand expression, which is 5. Now i is
5 again.
It seems to C++ compiler's bug...
Best regards,
Oleg.
|
| |
|
| |
 |
Sergey

|
Posted: Fri Sep 23 06:31:51 CDT 2005 |
Top |
Visual C#.Net >> Postfix increment
Well, this behaviour is well documented in C# Language specification:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csspec/html/vclrfcsharpspec_7_5_9.asp
1. The value of x is saved.
2. The selected operator is invoked with the saved value of x as its
argument.
3. The value returned by the operator is stored in the location given by
the evaluation of x.
4. The saved value of x becomes the result of the operation.
--
Sergey Bogdanov [.NET CF MVP, MCSD]
http://www.sergeybogdanov.com
Oleg Kharitonov wrote:
> Hello!
>
> I have found an interesting thing with postfix operator ++.
>
> What should contain the variable i after exceution the following code:
>
> int i = 5;
> i = i++;
>
> In VC++ 7.1 and VC++ 2005 beta 2 the variable i contains 6.
> But in C# 7.1 and C# 2005 beta 2 the variable i contains 5.
>
> Is it behaviour correct? Can anyone explain what is the correct result?
>
> Best regards,
> Oleg.
>
>
|
| |
|
| |
 |
Bill

|
Posted: Fri Sep 23 09:04:38 CDT 2005 |
Top |
Visual C#.Net >> Postfix increment
"Oleg Kharitonov" <EMail@HideDomain.com> wrote in message news:EMail@HideDomain.com...
> Hello!
>
> I have found an interesting thing with postfix operator ++.
>
> What should contain the variable i after exceution the following code:
>
> int i = 5;
> i = i++;
>
> In VC++ 7.1 and VC++ 2005 beta 2 the variable i contains 6.
> But in C# 7.1 and C# 2005 beta 2 the variable i contains 5.
>
> Is it behaviour correct? Can anyone explain what is the correct result?
>
> Best regards,
> Oleg.
The correct behavior is for the compiler to wipe out your harddrive and call you names, so as to
prevent you from writing any code that bad again. :^)
In C/C++ the behavior of
[ i = i++ ; ]
is undefined.
I have not found anywhere in the C# standard where they discuss sequence points yet.
So it is possible that this behavior is "Defined" in C#.
It should, however, be avoided at all costs
Bill
|
| |
|
| |
 |
Pete

|
Posted: Fri Sep 23 10:27:39 CDT 2005 |
Top |
Visual C#.Net >> Postfix increment
>
> "Oleg Kharitonov" <EMail@HideDomain.com> wrote in message
> news:EMail@HideDomain.com...
>> Hello!
>>
>> I have found an interesting thing with postfix operator ++.
>>
>> What should contain the variable i after exceution the following code:
>>
>> int i = 5;
>> i = i++;
>>
>> In VC++ 7.1 and VC++ 2005 beta 2 the variable i contains 6.
>> But in C# 7.1 and C# 2005 beta 2 the variable i contains 5.
>>
>> Is it behaviour correct? Can anyone explain what is the correct result?
>>
>> Best regards,
>> Oleg.
>
> The correct behavior is for the compiler to wipe out your harddrive and
> call you names, so as to prevent you from writing any code that bad again.
> :^)
>
> In C/C++ the behavior of
> [ i = i++ ; ]
> is undefined.
>
> I have not found anywhere in the C# standard where they discuss sequence
> points yet.
> So it is possible that this behavior is "Defined" in C#.
>
> It should, however, be avoided at all costs
>
> Bill
It's clearly defined in the C# standard. There's no reason to avoid it. If
it is undefined in C++, then it should be avoided in C++.
Pete
|
| |
|
| |
 |
Marcus

|
Posted: Fri Sep 23 14:28:44 CDT 2005 |
Top |
Visual C#.Net >> Postfix increment
On Fri, 23 Sep 2005 11:32:51 +0300, "Oleg Kharitonov"
<EMail@HideDomain.com> wrote:
>Hello!
>
>I have found an interesting thing with postfix operator ++.
>
>What should contain the variable i after exceution the following code:
>
>int i = 5;
>i = i++;
>
This post is rather long so if you don't want to read all of it, just
go to the bottom and read the conclusion.
In C++ this is an expression that has undefined results. Depending on
which compiler you use and what kind of optimization switches you
apply you will get different results. This is because the C++
specification doesn't contain a strict evaluation order of arguments.
If an expression contains methods with sideeffects (like ++) it can
easily introduce undefined results.
In C# evaluation order and assignment is strictly defined:
1. = and ?: evaluates from right-to-left
2. Binary operators evaluates from left to right. a+b+c => +(+(a,b),c)
3. Paranthesises and operator precedence can be used to change
evaluation order.
4. Once the operator ordering has been handled the execution order of
the arguments is from left to right.
For example:
result = G(C(A,B),D+E+F)
becomes
result = G(C(A,B),+(+(D,E),F)
which is
t1=A
t2=B
t3=C(t1,t2)
t4=D
t5=E
t6= t4 + t5
t7= F
t8= t6 + t7
t9 = G(t3,t8)
result = t9
--------------------------------------
Now that we have that we can look at the difference between var++ and
++var.
int varPlusPlus(ref int var)
{
int temp = var;
var = var + 1;
return temp;
}
int plusPlusVar(ref int var)
{
var = var +1;
return var;
}
As you can see, i++ increases the value of i, but returns the original
value. ++i increases the value of i and returns the new value. Now
that we know this, I will show what is happening with your code step
by step.
-------------------------------------
Assuming number = 10 and we do number = number + number++;
1) We evaluate 'number' which is the far most left argument. It
evaluates to 10.
2) We evaluate 'number++'. As I showed earlier the postfix ++
instruction does two things. It evaluates to the original value which
at this time is 10. It also increases the variable 'number' which from
now on has the value 11.
3) We run the function + on the two evaluated arguments 10 and 10.
This function returns 20.
4) The variable 'number' is set to 20 by the = sign operator.
-------------------------------------
To show, the importance of knowing that c# is evaluated left-to-right
consider this similar example.
Assuming number = 10 and we do number = number++ + number;
1) We evaluate 'number++'. It evaluates to the original value which
10. It also increases the variable 'number' which from now on has the
value 11.
2) We evaluate number which now has the value 11.
3) We run the function + on the two evaluated arguments 10 and 11.
This returns 21.
4) As always the last thing that happens on a row is the = statement
which sets 'number' to 21.
Notice how the result is different because of the order of the
arguments. This is the reason why you should avoid using ++ in complex
statements. In can cause severe headache when trying to read it which
can easily be solved by just splitting up the statement on two lines.
-------------------------------------
A final example with the prefix ++ statement.
Assuming number = 10 and we do number = ++number + ++number;
1) We evaluate the left most '++number'. It increases 'number' to 11
and returns 11.
2) We evaluate the right '++number'. It increases 'number' to 12 and
returns 12.
3) 11 + 12 = 23.
4) 'number' equals 23
I hope anyone that has read this far will have come to the same
conclusion as I have. Subexpressions with side effects should be
avoided as much as possible because it is way to easy to confuse even
a good programmer.
--
Marcus Andrén
|
| |
|
| |
 |
Jon

|
Posted: Fri Sep 23 14:45:52 CDT 2005 |
Top |
Visual C#.Net >> Postfix increment
Pete Davis <pdavis68@[nospam]hotmail.com> wrote:
> It's clearly defined in the C# standard. There's no reason to avoid it.
Just because behaviour is well-defined doesn't mean it shouldn't be
avoided. The fact that some people on this thread expected one answer
but got another makes it clear that it's not obvious what it does -
*that's* why it should be avoided.
--
Jon Skeet - <EMail@HideDomain.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
|
| |
|
| |
 |
Pete

|
Posted: Fri Sep 23 17:14:00 CDT 2005 |
Top |
Visual C#.Net >> Postfix increment
>> It's clearly defined in the C# standard. There's no reason to avoid it.
>
> Just because behaviour is well-defined doesn't mean it shouldn't be
> avoided. The fact that some people on this thread expected one answer
> but got another makes it clear that it's not obvious what it does -
> *that's* why it should be avoided.
>
Actually, I regretted the post right after I made it. You are correct. I
find it very annoying when C/C++ programmers take advantage of very obscure,
hard to decipher constructs for this same reason.
Pete
|
| |
|
| |
 |
| |
 |
Index ‹ DotNet ‹ Visual C#.Net |
- Next
- 1
- 2
- ADO >> DataTable LimitationsI've found a MSDN reference to the fact that an ADO.NET DataTable is limited
to 16,777,216 rows of data [1], but what I cannot find is a reference for
the maximum columns per DataTable, maximum bytes per DataRow, etc. Is this
information documented anywhere?
TIA!
- Christopher
[1]
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDataDataTableClassTopic.asp
- 3
- Dotnet >> XtraReports?Anyone is using XtraReports from www.devexpress.com?
Seems like a great piece of software and the price is right. Comments,
opinions?
Thanks!
- 4
- Dotnet >> Dynamically creating a Word documentI want to create a Word document that will display data from a database. I
don't want to create the file on the server, I just want to stream it out
directly to the user. When they click a button, the Word Save Open window
will open, and allow the user to Save or Open the document in Word. I know I
need to use response.binarywrite, but I don't know if it is possible to
create the binary object without first saving it to a temporary file. Would
I need to create a Word template, and how would I use it?
How would I get data from a data grid into this document?
- 5
- Visual C#.Net >> CS0536 ErrorThis is a multi-part message in MIME format.
------=_NextPart_000_000B_01C383D6.38C91C90
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi All,
I'm trying to generate a C# wrapper for a Windows type library using the =
following command line ...
csc /target:library /doc:Interop.MyLibrary.xml /unsafe =
Interop.MyLibrary.cs >Interop.MyLibrary.log
And receiving the following error message ...
Interop.MyLibrary.cs(499,18): error CS0536: =
'Interop.MyLibrary.IImpBaseCollection_SinkHelper' does not implement =
interface member 'Interop.MyLibrary.IImpBaseCollection.Item(object)'. =
'Interop.MyLibrary.IImpBaseCollection_SinkHelper.Item(object)' is either =
static, not public, or has the wrong return type.
Here's the code....
The line where the error occurs is in Bold Blue
Any ideas appreciated!! ;-)
Thanks,
Roland
-----------------
/// <summary><para><c>IImpBaseCollection</c> interface.</para></summary>
[Guid("5616A320-AB4D-11D0-8E2F-00A0C9050603")]
[ComImport]
[TypeLibType((short)4096)]
[DefaultMember("Item")]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)]
public interface IImpBaseCollection: System.Collections.IEnumerable
{
/// <summary><para><c>Item</c> method of <c>IImpBaseCollection</c> =
interface.</para></summary>
/// <remarks><para>An original IDL definition of <c>Item</c> method was =
the following: <c>HRESULT Item (VARIANT nIndex, [out, retval] =
IDispatch** ReturnValue)</c>;</para></remarks>
// IDL: HRESULT Item (VARIANT nIndex, [out, retval] IDispatch** =
ReturnValue);
// VB6: Function Item (ByVal nIndex As Any) As IDispatch
[DispId(0)]
[return: MarshalAs(UnmanagedType.IDispatch)]
object Item (object nIndex);
/// <summary><para><c>_NewEnum</c> property of <c>IImpBaseCollection</c> =
interface.</para></summary>
/// <remarks><para>An original IDL definition of <c>_NewEnum</c> =
property was the following: <c>IUnknown* _NewEnum</c>;</para></remarks>
// IDL: IUnknown* _NewEnum;
// VB6: _NewEnum As IUnknown
object _NewEnum
{
// IDL: HRESULT _NewEnum ([out, retval] IUnknown** ReturnValue);
// VB6: Function _NewEnum As IUnknown
[DispId(-4)]
[return: MarshalAs(UnmanagedType.IUnknown)]
get;
}
/// <summary><para>Parent property of IImpBaseCollection =
interface.</para></summary>
/// <remarks><para>An original IDL definition of <c>Parent</c> property =
was the following: <c>IDispatch* Parent</c>;</para></remarks>
// IDL: IDispatch* Parent;
// VB6: Property Parent As IDispatch
[DispId(2)]
object Parent
{
[return: MarshalAs(UnmanagedType.IDispatch)]
get;
}
/// <summary><para>Count property of IImpBaseCollection =
interface.</para></summary>
/// <remarks><para>An original IDL definition of <c>Count</c> property =
was the following: <c>long Count</c>;</para></remarks>
// IDL: long Count;
// VB6: Property Count As Long
[DispId(3)]
int Count
{
get;
}
}
/// <summary><para>Delegate for handling <c>Item</c> event of =
<c>IImpBaseCollection</c> interface.</para></summary>
/// <remarks><para>An original IDL definition of <c>Item</c> event was =
the following: <c>HRESULT IImpBaseCollection_ItemEventHandler (VARIANT =
nIndex, [out, retval] IDispatch** ReturnValue)</c>;</para></remarks>
// IDL: HRESULT IImpBaseCollection_ItemEventHandler (VARIANT nIndex, =
[out, retval] IDispatch** ReturnValue);
// VB6: Function IImpBaseCollection_ItemEventHandler (ByVal nIndex As =
Any) As IDispatch
[return: MarshalAs(UnmanagedType.IDispatch)]
public delegate object IImpBaseCollection_ItemEventHandler (object =
nIndex);
/// <summary><para>Delegate for handling <c>_NewEnum</c> event of =
<c>IImpBaseCollection</c> interface.</para></summary>
/// <remarks><para>An original IDL definition of <c>_NewEnum</c> event =
was the following: <c>HRESULT IImpBaseCollection__NewEnumEventHandler =
([out, retval] IUnknown** ReturnValue)</c>;</para></remarks>
// IDL: HRESULT IImpBaseCollection__NewEnumEventHandler ([out, retval] =
IUnknown** ReturnValue);
// VB6: Function IImpBaseCollection__NewEnumEventHandler As IUnknown
[return: MarshalAs(UnmanagedType.IUnknown)]
public delegate object IImpBaseCollection__NewEnumEventHandler () /* =
property get method */;
/// <summary><para>Declaration of events of <c>IImpBaseCollection</c> =
source interface.</para></summary>
[ComEventInterface(typeof(IImpBaseCollection),typeof(IImpBaseCollection_E=
ventProvider))]
[ComVisible(false)]
public interface IImpBaseCollection_Event
{
/// <summary><para><c>Item</c> event of <c>IImpBaseCollection</c> =
interface.</para></summary>
event IImpBaseCollection_ItemEventHandler Item;
/// <summary><para><c>_NewEnum</c> event of <c>IImpBaseCollection</c> =
interface.</para></summary>
event IImpBaseCollection__NewEnumEventHandler _NewEnum;
}
[ClassInterface(ClassInterfaceType.None)]
internal class IImpBaseCollection_SinkHelper: IImpBaseCollection
{
public int Cookie =3D 0;
public event IImpBaseCollection_ItemEventHandler ItemDelegate =3D null;
public void Set_ItemDelegate(IImpBaseCollection_ItemEventHandler deleg)
{
ItemDelegate =3D deleg;
}
public bool Is_ItemDelegate(IImpBaseCollection_ItemEventHandler deleg)
{
return (ItemDelegate =3D=3D deleg);
}
public void Clear_ItemDelegate()
{
ItemDelegate =3D null;
}
void Item (object nIndex)
{
if (ItemDelegate!=3Dnull)
ItemDelegate(nIndex);
}
public event IImpBaseCollection__NewEnumEventHandler _NewEnumDelegate =
=3D null;
public void Set__NewEnumDelegate(IImpBaseCollection__NewEnumEventHandler =
deleg)
{
_NewEnumDelegate =3D deleg;
}
public bool Is__NewEnumDelegate(IImpBaseCollection__NewEnumEventHandler =
deleg)
{
return (_NewEnumDelegate =3D=3D deleg);
}
public void Clear__NewEnumDelegate()
{
_NewEnumDelegate =3D null;
}
void _NewEnum () /* property get method */
{
if (_NewEnumDelegate!=3Dnull)
_NewEnumDelegate();
}
}
------=_NextPart_000_000B_01C383D6.38C91C90
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1141" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV>Hi All,</DIV>
<DIV> </DIV>
<DIV>I'm trying to generate a C# wrapper for a Windows type library =
using the=20
following command line ...</DIV>
<DIV> </DIV>
<DIV><STRONG>csc /target:library /doc:Interop.MyLibrary.xml /unsafe=20
Interop.MyLibrary.cs >Interop.MyLibrary.log</STRONG></DIV>
<DIV> </DIV>
<DIV>And receiving the following error message ...</DIV>
<DIV> </DIV>
<DIV><FONT face=3Dt color=3D#0000ff>Interop.MyLibrary.cs(499,18): error =
CS0536:=20
'Interop.MyLibrary.IImpBaseCollection_SinkHelper' does not implement =
interface=20
member 'Interop.MyLibrary.IImpBaseCollection.Item(object)'.=20
'Interop.MyLibrary.IImpBaseCollection_SinkHelper.Item(object)' is either =
static,=20
not public, or has the wrong return type.</FONT></DIV>
<DIV> </DIV>
<DIV>Here's the code....</DIV>
<DIV> </DIV>
<DIV><FONT size=3D2><FONT color=3D#808080><FONT color=3D#000000 =
size=3D3>The line where=20
the error occurs is in <STRONG><FONT color=3D#0000ff>Bold=20
Blue</FONT></STRONG></FONT></FONT></FONT></DIV>
<DIV> </DIV>
<DIV>Any ideas appreciated!! ;-)</DIV>
<DIV> </DIV>
<DIV>Thanks,</DIV>
<DIV>Roland</DIV>
<DIV> </DIV>
<DIV>-----------------</DIV>
<DIV> </DIV>
<DIV><FONT size=3D2><FONT color=3D#808080></FONT></FONT> </DIV>
<DIV><FONT size=3D2><FONT color=3D#808080>///</FONT><FONT =
color=3D#008000>=20
</FONT><FONT =
color=3D#808080><summary><para><c></FONT><FONT=20
color=3D#008000>IImpBaseCollection</FONT><FONT=20
color=3D#808080></c></FONT><FONT color=3D#008000> =
interface.</FONT><FONT=20
color=3D#808080></para></summary></DIV>
<DIV></FONT></FONT>
<P><FONT =
size=3D2>[Guid("5616A320-AB4D-11D0-8E2F-00A0C9050603")]</FONT></P>
<P><FONT size=3D2>[ComImport]</FONT></P>
<P><FONT size=3D2>[TypeLibType((<FONT =
color=3D#0000ff>short</FONT>)4096)]</FONT></P>
<P><FONT size=3D2>[DefaultMember("Item")]</FONT></P>
<P><FONT=20
size=3D2>[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)]<=
/FONT></P>
<P><FONT size=3D2><FONT color=3D#0000ff>public</FONT> <FONT=20
color=3D#0000ff>interface</FONT> IImpBaseCollection:=20
System.Collections.IEnumerable</FONT></P>
<P><FONT size=3D2>{</FONT></P>
<P><FONT size=3D2><FONT color=3D#808080>///</FONT><FONT color=3D#008000> =
</FONT><FONT=20
color=3D#808080><summary><para><c></FONT><FONT=20
color=3D#008000>Item</FONT><FONT color=3D#808080></c></FONT><FONT=20
color=3D#008000> method of </FONT><FONT =
color=3D#808080><c></FONT><FONT=20
color=3D#008000>IImpBaseCollection</FONT><FONT=20
color=3D#808080></c></FONT><FONT color=3D#008000> =
interface.</FONT><FONT=20
color=3D#808080></para></summary></P></FONT></FONT>
<P><FONT size=3D2><FONT color=3D#808080>///</FONT><FONT color=3D#008000> =
</FONT><FONT=20
color=3D#808080><remarks><para></FONT><FONT =
color=3D#008000>An original=20
IDL definition of </FONT><FONT color=3D#808080><c></FONT><FONT=20
color=3D#008000>Item</FONT><FONT color=3D#808080></c></FONT><FONT=20
color=3D#008000> method was the following: </FONT><FONT=20
color=3D#808080><c></FONT><FONT color=3D#008000>HRESULT Item =
(VARIANT nIndex,=20
[out, retval] IDispatch** ReturnValue)</FONT><FONT=20
color=3D#808080></c></FONT><FONT color=3D#008000>;</FONT><FONT=20
color=3D#808080></para></remarks></P></FONT></FONT>
<P><FONT color=3D#008000><FONT size=3D2>// IDL: HRESULT Item (VARIANT =
nIndex, [out,=20
retval] IDispatch** ReturnValue);</FONT></P></FONT>
<P><FONT color=3D#008000><FONT size=3D2>// VB6: Function Item (ByVal =
nIndex As Any)=20
As IDispatch</FONT></P></FONT>
<P><STRONG><FONT color=3D#ff0000>[DispId(0)]</FONT></STRONG></P>
<P><STRONG><FONT color=3D#ff0000>[return:=20
MarshalAs(UnmanagedType.IDispatch)]</FONT></STRONG></P>
<P><STRONG><FONT color=3D#ff0000>object Item (object =
nIndex);</FONT></STRONG></P>
<P><FONT size=3D2><FONT color=3D#808080>///</FONT><FONT color=3D#008000> =
</FONT><FONT=20
color=3D#808080><summary><para><c></FONT><FONT=20
color=3D#008000>_NewEnum</FONT><FONT =
color=3D#808080></c></FONT><FONT=20
color=3D#008000> property of </FONT><FONT =
color=3D#808080><c></FONT><FONT=20
color=3D#008000>IImpBaseCollection</FONT><FONT=20
color=3D#808080></c></FONT><FONT color=3D#008000> =
interface.</FONT><FONT=20
color=3D#808080></para></summary></P></FONT></FONT>
<P><FONT size=3D2><FONT color=3D#808080>///</FONT><FONT color=3D#008000> =
</FONT><FONT=20
color=3D#808080><remarks><para></FONT><FONT =
color=3D#008000>An original=20
IDL definition of </FONT><FONT color=3D#808080><c></FONT><FONT=20
color=3D#008000>_NewEnum</FONT><FONT =
color=3D#808080></c></FONT><FONT=20
color=3D#008000> property was the following: </FONT><FONT=20
color=3D#808080><c></FONT><FONT color=3D#008000>IUnknown* =
_NewEnum</FONT><FONT=20
color=3D#808080></c></FONT><FONT color=3D#008000>;</FONT><FONT=20
color=3D#808080></para></remarks></P></FONT></FONT>
<P><FONT color=3D#008000><FONT size=3D2>// IDL: IUnknown*=20
_NewEnum;</FONT></P></FONT>
<P><FONT color=3D#008000><FONT size=3D2>// VB6: _NewEnum As=20
IUnknown</FONT></P></FONT>
<P><FONT size=3D2><FONT color=3D#0000ff>object</FONT> =
_NewEnum</FONT></P>
<P><FONT size=3D2>{</FONT></P>
<P><FONT color=3D#008000><FONT size=3D2>// IDL: HRESULT _NewEnum ([out, =
retval]=20
IUnknown** ReturnValue);</FONT></P></FONT>
<P><FONT color=3D#008000><FONT size=3D2>// VB6: Function _NewEnum As=20
IUnknown</FONT></P></FONT>
<P><FONT size=3D2>[DispId(-4)]</FONT></P>
<P><FONT size=3D2>[<FONT color=3D#0000ff>return</FONT>:=20
MarshalAs(UnmanagedType.IUnknown)]</FONT></P>
<P><FONT size=3D2><FONT color=3D#0000ff>get</FONT>;</FONT></P>
<P><FONT size=3D2>}</FONT></P>
<P><FONT size=3D2><FONT color=3D#808080>///</FONT><FONT color=3D#008000> =
</FONT><FONT=20
color=3D#808080><summary><para></FONT><FONT =
color=3D#008000>Parent=20
property of IImpBaseCollection interface.</FONT><FONT=20
color=3D#808080></para></summary></P></FONT></FONT>
<P><FONT size=3D2><FONT color=3D#808080>///</FONT><FONT color=3D#008000> =
</FONT><FONT=20
color=3D#808080><remarks><para></FONT><FONT =
color=3D#008000>An original=20
IDL definition of </FONT><FONT color=3D#808080><c></FONT><FONT=20
color=3D#008000>Parent</FONT><FONT =
color=3D#808080></c></FONT><FONT=20
color=3D#008000> property was the following: </FONT><FONT=20
color=3D#808080><c></FONT><FONT color=3D#008000>IDispatch* =
Parent</FONT><FONT=20
color=3D#808080></c></FONT><FONT color=3D#008000>;</FONT><FONT=20
color=3D#808080></para></remarks></P></FONT></FONT>
<P><FONT color=3D#008000><FONT size=3D2>// IDL: IDispatch* =
Parent;</FONT></P></FONT>
<P><FONT color=3D#008000><FONT size=3D2>// VB6: Property Parent As=20
IDispatch</FONT></P></FONT>
<P><FONT size=3D2>[DispId(2)]</FONT></P>
<P><FONT size=3D2><FONT color=3D#0000ff>object</FONT> Parent</FONT></P>
<P><FONT size=3D2>{</FONT></P>
<P><FONT size=3D2>[<FONT color=3D#0000ff>return</FONT>:=20
MarshalAs(UnmanagedType.IDispatch)]</FONT></P>
<P><FONT size=3D2><FONT color=3D#0000ff>get</FONT>;</FONT></P>
<P><FONT size=3D2>}</FONT></P>
<P><FONT size=3D2><FONT color=3D#808080>///</FONT><FONT color=3D#008000> =
</FONT><FONT=20
color=3D#808080><summary><para></FONT><FONT =
color=3D#008000>Count=20
property of IImpBaseCollection interface.</FONT><FONT=20
color=3D#808080></para></summary></P></FONT></FONT>
<P><FONT size=3D2><FONT color=3D#808080>///</FONT><FONT color=3D#008000> =
</FONT><FONT=20
color=3D#808080><remarks><para></FONT><FONT =
color=3D#008000>An original=20
IDL definition of </FONT><FONT color=3D#808080><c></FONT><FONT=20
color=3D#008000>Count</FONT><FONT color=3D#808080></c></FONT><FONT =
color=3D#008000> property was the following: </FONT><FONT=20
color=3D#808080><c></FONT><FONT color=3D#008000>long =
Count</FONT><FONT=20
color=3D#808080></c></FONT><FONT color=3D#008000>;</FONT><FONT=20
color=3D#808080></para></remarks></P></FONT></FONT>
<P><FONT color=3D#008000><FONT size=3D2>// IDL: long =
Count;</FONT></P></FONT>
<P><FONT color=3D#008000><FONT size=3D2>// VB6: Property Count As=20
Long</FONT></P></FONT>
<P><FONT size=3D2>[DispId(3)]</FONT></P>
<P><FONT size=3D2><FONT color=3D#0000ff>int</FONT> Count</FONT></P>
<P><FONT size=3D2>{</FONT></P>
<P><FONT size=3D2><FONT color=3D#0000ff>get</FONT>;</FONT></P>
<P><FONT size=3D2>}</FONT></P>
<P><FONT size=3D2>}</FONT></P>
<P><FONT size=3D2><FONT color=3D#808080>///</FONT><FONT color=3D#008000> =
</FONT><FONT=20
color=3D#808080><summary><para></FONT><FONT =
color=3D#008000>Delegate for=20
handling </FONT><FONT color=3D#808080><c></FONT><FONT=20
color=3D#008000>Item</FONT><FONT color=3D#808080></c></FONT><FONT=20
color=3D#008000> event of </FONT><FONT =
color=3D#808080><c></FONT><FONT=20
color=3D#008000>IImpBaseCollection</FONT><FONT=20
color=3D#808080></c></FONT><FONT color=3D#008000> =
interface.</FONT><FONT=20
color=3D#808080></para></summary></P></FONT></FONT>
<P><FONT size=3D2><FONT color=3D#808080>///</FONT><FONT color=3D#008000> =
</FONT><FONT=20
color=3D#808080><remarks><para></FONT><FONT =
color=3D#008000>An original=20
IDL definition of </FONT><FONT color=3D#808080><c></FONT><FONT=20
color=3D#008000>Item</FONT><FONT color=3D#808080></c></FONT><FONT=20
color=3D#008000> event was the following: </FONT><FONT=20
color=3D#808080><c></FONT><FONT color=3D#008000>HRESULT=20
IImpBaseCollection_ItemEventHandler (VARIANT nIndex, [out, retval] =
IDispatch**=20
ReturnValue)</FONT><FONT color=3D#808080></c></FONT><FONT=20
color=3D#008000>;</FONT><FONT=20
color=3D#808080></para></remarks></P></FONT></FONT>
<P><FONT color=3D#008000><FONT size=3D2>// IDL: HRESULT=20
IImpBaseCollection_ItemEventHandler (VARIANT nIndex, [out, retval] =
IDispatch**=20
ReturnValue);</FONT></P></FONT>
<P><FONT color=3D#008000><FONT size=3D2>// VB6: Function=20
IImpBaseCollection_ItemEventHandler (ByVal nIndex As Any) As=20
IDispatch</FONT></P></FONT>
<P><FONT size=3D2>[<FONT color=3D#0000ff>return</FONT>:=20
MarshalAs(UnmanagedType.IDispatch)]</FONT></P>
<P><FONT size=3D2><FONT color=3D#0000ff>public</FONT> <FONT=20
color=3D#0000ff>delegate</FONT> <FONT color=3D#0000ff>object</FONT>=20
IImpBaseCollection_ItemEventHandler (<FONT color=3D#0000ff>object</FONT> =
nIndex);</FONT></P>
<P><FONT size=3D2><FONT color=3D#808080>///</FONT><FONT color=3D#008000> =
</FONT><FONT=20
color=3D#808080><summary><para></FONT><FONT =
color=3D#008000>Delegate for=20
handling </FONT><FONT color=3D#808080><c></FONT><FONT=20
color=3D#008000>_NewEnum</FONT><FONT =
color=3D#808080></c></FONT><FONT=20
color=3D#008000> event of </FONT><FONT =
color=3D#808080><c></FONT><FONT=20
color=3D#008000>IImpBaseCollection</FONT><FONT=20
color=3D#808080></c></FONT><FONT color=3D#008000> =
interface.</FONT><FONT=20
color=3D#808080></para></summary></P></FONT></FONT>
<P><FONT size=3D2><FONT color=3D#808080>///</FONT><FONT color=3D#008000> =
</FONT><FONT=20
color=3D#808080><remarks><para></FONT><FONT =
color=3D#008000>An original=20
IDL definition of </FONT><FONT color=3D#808080><c></FONT><FONT=20
color=3D#008000>_NewEnum</FONT><FONT =
color=3D#808080></c></FONT><FONT=20
color=3D#008000> event was the following: </FONT><FONT=20
color=3D#808080><c></FONT><FONT color=3D#008000>HRESULT=20
IImpBaseCollection__NewEnumEventHandler ([out, retval] IUnknown**=20
ReturnValue)</FONT><FONT color=3D#808080></c></FONT><FONT=20
color=3D#008000>;</FONT><FONT=20
color=3D#808080></para></remarks></P></FONT></FONT>
<P><FONT color=3D#008000><FONT size=3D2>// IDL: HRESULT=20
IImpBaseCollection__NewEnumEventHandler ([out, retval] IUnknown**=20
ReturnValue);</FONT></P></FONT>
<P><FONT color=3D#008000><FONT size=3D2>// VB6: Function=20
IImpBaseCollection__NewEnumEventHandler As IUnknown</FONT></P></FONT>
<P><FONT size=3D2>[<FONT color=3D#0000ff>return</FONT>:=20
MarshalAs(UnmanagedType.IUnknown)]</FONT></P>
<P><FONT size=3D2><FONT color=3D#0000ff>public</FONT> <FONT=20
color=3D#0000ff>delegate</FONT> <FONT color=3D#0000ff>object</FONT>=20
IImpBaseCollection__NewEnumEventHandler () <FONT color=3D#008000>/* =
property get=20
method */</FONT>;</FONT></P>
<P><FONT size=3D2><FONT color=3D#808080>///</FONT><FONT color=3D#008000> =
</FONT><FONT=20
color=3D#808080><summary><para></FONT><FONT =
color=3D#008000>Declaration=20
of events of </FONT><FONT color=3D#808080><c></FONT><FONT=20
color=3D#008000>IImpBaseCollection</FONT><FONT=20
color=3D#808080></c></FONT><FONT color=3D#008000> source=20
interface.</FONT><FONT=20
color=3D#808080></para></summary></P></FONT></FONT>
<P><FONT size=3D2>[ComEventInterface(<FONT=20
color=3D#0000ff>typeof</FONT>(IImpBaseCollection),<FONT=20
color=3D#0000ff>typeof</FONT>(IImpBaseCollection_EventProvider))]</FONT><=
/P>
<P><FONT size=3D2>[ComVisible(<FONT =
color=3D#0000ff>false</FONT>)]</FONT></P>
<P><FONT size=3D2><FONT color=3D#0000ff>public</FONT> <FONT=20
color=3D#0000ff>interface</FONT> IImpBaseCollection_Event</FONT></P>
<P><FONT size=3D2>{</FONT></P>
<P><FONT size=3D2><FONT color=3D#808080>///</FONT><FONT color=3D#008000> =
</FONT><FONT=20
color=3D#808080><summary><para><c></FONT><FONT=20
color=3D#008000>Item</FONT><FONT color=3D#808080></c></FONT><FONT=20
color=3D#008000> event of </FONT><FONT =
color=3D#808080><c></FONT><FONT=20
color=3D#008000>IImpBaseCollection</FONT><FONT=20
color=3D#808080></c></FONT><FONT color=3D#008000> =
interface.</FONT><FONT=20
color=3D#808080></para></summary></P></FONT></FONT>
<P><FONT size=3D2><FONT color=3D#0000ff>event</FONT>=20
IImpBaseCollection_ItemEventHandler Item;</FONT></P>
<P><FONT size=3D2><FONT color=3D#808080>///</FONT><FONT color=3D#008000> =
</FONT><FONT=20
color=3D#808080><summary><para><c></FONT><FONT=20
color=3D#008000>_NewEnum</FONT><FONT =
color=3D#808080></c></FONT><FONT=20
color=3D#008000> event of </FONT><FONT =
color=3D#808080><c></FONT><FONT=20
color=3D#008000>IImpBaseCollection</FONT><FONT=20
color=3D#808080></c></FONT><FONT color=3D#008000> =
interface.</FONT><FONT=20
color=3D#808080></para></summary></P></FONT></FONT>
<P><FONT size=3D2><FONT color=3D#0000ff>event</FONT>=20
IImpBaseCollection__NewEnumEventHandler _NewEnum;</FONT></P>
<P><FONT size=3D2>}</FONT></P>
<P><FONT size=3D2>[ClassInterface(ClassInterfaceType.None)]</FONT></P>
<P><FONT color=3D#0000ff><STRONG>internal class =
IImpBaseCollection_SinkHelper:=20
IImpBaseCollection</STRONG></FONT></P>
<P><FONT size=3D2>{</FONT></P>
<P><FONT size=3D2><FONT color=3D#0000ff>public</FONT> <FONT =
color=3D#0000ff>int</FONT>=20
Cookie =3D 0;</FONT></P>
<P><FONT size=3D2><FONT color=3D#0000ff>public</FONT> <FONT=20
color=3D#0000ff>event</FONT> IImpBaseCollection_ItemEventHandler =
ItemDelegate =3D=20
<FONT color=3D#0000ff>null</FONT>;</FONT></P>
<P><FONT size=3D2><FONT color=3D#0000ff>public</FONT> <FONT=20
color=3D#0000ff>void</FONT> =
Set_ItemDelegate(IImpBaseCollection_ItemEventHandler=20
deleg)</FONT></P>
<P><FONT size=3D2>{</FONT></P>
<P><FONT size=3D2>ItemDelegate =3D deleg;</FONT></P>
<P><FONT size=3D2>}</FONT></P>
<P><FONT size=3D2><FONT color=3D#0000ff>public</FONT> <FONT=20
color=3D#0000ff>bool</FONT> =
Is_ItemDelegate(IImpBaseCollection_ItemEventHandler=20
deleg)</FONT></P>
<P><FONT size=3D2>{</FONT></P>
<P><FONT size=3D2><FONT color=3D#0000ff>return</FONT> (ItemDelegate =
=3D=3D=20
deleg);</FONT></P>
<P><FONT size=3D2>}</FONT></P>
<P><FONT size=3D2><FONT color=3D#0000ff>public</FONT> <FONT=20
color=3D#0000ff>void</FONT> Clear_ItemDelegate()</FONT></P>
<P><FONT size=3D2>{</FONT></P>
<P><FONT size=3D2>ItemDelegate =3D <FONT =
color=3D#0000ff>null</FONT>;</FONT></P>
<P><FONT size=3D2>}</FONT></P>
<P><STRONG><FONT color=3D#ff0000>void Item (object =
nIndex)</FONT></STRONG></P>
<P><STRONG><FONT color=3D#ff0000>{</FONT></STRONG></P>
<P><STRONG><FONT color=3D#ff0000>if =
(ItemDelegate!=3Dnull)</FONT></STRONG></P>
<P><STRONG><FONT =
color=3D#ff0000>ItemDelegate(nIndex);</FONT></STRONG></P>
<P><STRONG><FONT color=3D#ff0000>}</FONT></STRONG></P>
<P><FONT size=3D2><FONT color=3D#0000ff>public</FONT> <FONT=20
color=3D#0000ff>event</FONT> IImpBaseCollection__NewEnumEventHandler=20
_NewEnumDelegate =3D <FONT color=3D#0000ff>null</FONT>;</FONT></P>
<P><FONT size=3D2><FONT color=3D#0000ff>public</FONT> <FONT=20
color=3D#0000ff>void</FONT>=20
Set__NewEnumDelegate(IImpBaseCollection__NewEnumEventHandler =
deleg)</FONT></P>
<P><FONT size=3D2>{</FONT></P>
<P><FONT size=3D2>_NewEnumDelegate =3D deleg;</FONT></P>
<P><FONT size=3D2>}</FONT></P>
<P><FONT size=3D2><FONT color=3D#0000ff>public</FONT> <FONT=20
color=3D#0000ff>bool</FONT>=20
Is__NewEnumDelegate(IImpBaseCollection__NewEnumEventHandler =
deleg)</FONT></P>
<P><FONT size=3D2>{</FONT></P>
<P><FONT size=3D2><FONT color=3D#0000ff>return</FONT> (_NewEnumDelegate =
=3D=3D=20
deleg);</FONT></P>
<P><FONT size=3D2>}</FONT></P>
<P><FONT size=3D2><FONT color=3D#0000ff>public</FONT> <FONT=20
color=3D#0000ff>void</FONT> Clear__NewEnumDelegate()</FONT></P>
<P><FONT size=3D2>{</FONT></P>
<P><FONT size=3D2>_NewEnumDelegate =3D <FONT =
color=3D#0000ff>null</FONT>;</FONT></P>
<P><FONT size=3D2>}</FONT></P>
<P><FONT size=3D2><FONT color=3D#0000ff>void</FONT> _NewEnum () <FONT=20
color=3D#008000>/* property get method */</P></FONT></FONT>
<P><FONT size=3D2>{</FONT></P>
<P><FONT size=3D2><FONT color=3D#0000ff>if</FONT> =
(_NewEnumDelegate!=3D<FONT=20
color=3D#0000ff>null</FONT>)</FONT></P>
<P><FONT size=3D2>_NewEnumDelegate();</FONT></P>
<P><FONT size=3D2>}</FONT></P>
<P><FONT size=3D2>}</FONT><FONT size=3D1></P></FONT></DIV></BODY></HTML>
------=_NextPart_000_000B_01C383D6.38C91C90--
- 6
- Visual C#.Net >> using HtmlInputFile problemHi,
I'm trying to upload a file and I do that with this code, but there is a
thing which doesn't work. I can't understand how to check if it isn't
written the path to the file(the text field of <input> control is empty) or
it is.
I have tryed with the following:
if( filMyFile.PostedFile != null) //HtmlInputFile filMyFile;
{
code
}
else
{
code
}
and with:
if(filMyFile.Value=="")
{
code
}
else
{
code
}
but everytime( when the text filed with the path is empty or filled) the if
statement works in same way.
How could be checked if the path is filled or it isn't?
Here is my code.Thank you in advance!
private void Button1_Click(object sender, System.EventArgs e)
{
msg.Text="";
if(filMyFile.PostedFile != null)
{
try
{
// Get a reference to PostedFile object
HttpPostedFile myFile = filMyFile.PostedFile;
// Get size of uploaded file
int nFileLen = myFile.ContentLength;
if(myFile.ContentType.CompareTo("image/gif")==0)
{
// Allocate a buffer for reading of the file
byte[] myData = new byte[nFileLen];
// Read uploaded file from the Stream
myFile.InputStream.Read(myData, 0, nFileLen);
string strFilename = Path.GetFileName(myFile.FileName);
string strDir = "c:\\Inetpub\\wwwroot\\Estates\\Files\\" +
Session["usrName"].ToString();
Directory.CreateDirectory( strDir);
string
strRoute=MapPath("/Estates/Files/"+Session["usrName"].ToString()+"/"+strFile
name);
//string strFilename = Path.GetFileName(myFile.FileName);
//string strRoute=MapPath("/Estates/Files/"+strFilename );
WriteToFile(strRoute,myData);
msg.Text="The file was attached";
}
else
{
msg.Text="This file is not a gif!!!";
}
}
catch(Exception exc)
{
msg.Text = "Error by saving: " + exc.ToString();
}
}
else
{
msg.Text="Please, atach your file!";
return;
}
}
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.729 / Virus Database: 484 - Release Date: 27.7.2004 a.
- 7
- Visual C#.Net >> Creating a dynamic array...Hello.
I have figured out how to create an instance of an object only knowing the
type by string.
string sName = "MyClassName";
Type t = Type.GetType(sName);
Object objNew = Activator.CreateInstance(t);
This works, but now I need to declare an array like
Object[] objNew = Activator.CreateInstance(t)[0];
This doesn't work. Can anyone help?
Thanks.
Matthew Wells
Matthew.Wells@FirstByte.net
- 8
- Dotnet >> Logging Into a ServerHello All,
I'm hoping someone can point me in the right direction. This is outside of
my experience with VB. I have an application (written in VB.NET) that
allows a user to enter a part of the file name and all file matches in a
specific
directory are copied to the user's desktop. It's a simple but useful tool.
Now an outside company requires access to the data. The files have been
moved to a Windows 2000 server accessible via the internet (i.e. outside the
firewall) so the other company can access the files. Both companies are
going to use this program. Since this server is not on our (or any) domain
I must log into that server. Therein lies my question. How do I
programmatically supply a user name and password to the server? We do not
want the other company to know the user name and password to the server.
The "best" solution is a web application, but I need to get this working
immediately and I haven't much experience with ASP.
Thank you for your help.
Chris
- 9
- Net Framework >> Calling URL through Proxy server(Address and Port)/Proxy ScriptHi All,
i m develpoing a .net Window application which has
4 texboxes(tbxURLmfor URL in URL Frame,tbxAddress for address in Proxy
server frame,tbxPort for port in proxy server frame,tbxProxyScript for proxy
script in proxy script frame) and a test button..The requirment is given below
STEP BY STEP GUIDE
1. Input the URL you want to test
2. Choose Proxy script/Proxy server with Address and Port Information/No proxy
3. Enter url to proxy script or info for proxy server in respective text box
4. Press test-button
---------------My Code is -------------------------------------------------
DateTime dt1 = DateTime.Now;
System.Net.HttpWebRequest myReq =
(HttpWebRequest)WebRequest.Create(tbxURL.Text.ToString());
//GetResponse for this request.
HttpWebResponse response = (HttpWebResponse)myReq.GetResponse();
DateTime dt2 = DateTime.Now;
lblTimeTaken.Text = Convert.ToString(dt2.Subtract(dt1));
--------------------------------------------------------------------
in this code , i m unable to set the value of proxy script textbox ,if any
or proxy server(Address and port) ,only thing which i do threough this code
is sending the url without any proxyscript ans proxy server(address and port
info) Can anybody tell me how can i do this thorugh the code....
..
i m working on window application as i need *.exe file rather than install
file ....
Thanks,
Deepak
- 10
- 11
- Net Framework >> Is this s bug?Hi All
I have one query, and need urgent help here. It is related with Windows
Address
Book(WAB). Suppose I open a link to WAB through my application's (developed
in VC++) dialog box. Now, if I get the focus back on my dialog box with the
WAB still opened(not in focus though), I cannot navigate through the
controls in my dialog box through the TAB key. Also, ENTER key does not
work. But the dialog box starts responding to the TAB and ENTER keys as soon
as WAB is closed. Why is it happening like this. I had downloaded a sample
WAB program from www.microsoft.com and this program too had the same
problem. I want to know if it is a bug or a normal behavior in VC++ and WAB
integration. Is there any workaround to this problem.
Thanks for your time.
Regards,
AA
- 12
- Net Framework >> Installing .net framework 3.0The uninstall tool indicates that all previous installs have been
uninstalled. The download of 30MB but then just as the installation starts I
get the error log:
[09/29/06,21:45:35] VS Scenario: [2] CPrevProductInstalledCheck failed :
<font face=Verdana size=8pt>
Thank you for participating in the Beta program. You must uninstall all
pre-release products in a specific order before you can continue with setup.
For detailed information, see the <a color=#3F4F7F HOVER-COLOR=#C3120C
href="http://go.microsoft.com/fwlink/?LinkId=54981">uninstall support
page</a> and the <a color=#3F4F7F HOVER-COLOR=#C3120C
href="http://go.microsoft.com/fwlink/?LinkId=70837">readme</a>.<br> -
WinFX Runtime Components 3.0 - Beta 2<br> - Windows Communication
Foundation
[09/29/06,21:45:36] VS Scenario: [2] Failed to pass the Warnings/Blocks
checks in CVSScenario::Start()
[09/29/06,22:12:18] VS Scenario: [2] CPrevProductInstalledCheck failed :
<font face=Verdana size=8pt>
--
David Houliston
MCAD
- 13
- Microsoft Project >> error: valid product key must be set to create an admin imageI'm trying to set up an administrative installation point for project 2002
professional including MUI-packs (german; maybe french, too). When installing
the MUI-Pack to the administrative share using the usual command
"<cdrom>:\1031\setup /a"
the setup stops after completing all dialogs (accept, installation path)with
installer error
"A valid Product Key must be set to create an Admin image"
I was never asked for a licensing key and IMHO the MUI kits don't handle
licensing, anyway. I'm using Project 2002 pro with volume licensing key and
the MUI CD2 from MSDN Subscriber Downloads. Poject 2002 us-english
kernel runs without problems.
It's independent of the installation path I choose.
Ideas?
- 14
- Visual C#.Net >> Folder rights...I'm creating a new folder using Directory.CreateDirectory() method.
How to set "FullControl" rights to "Everyone" group on this folder?
Where to obtain an "Everyone" identity string? I can't just put
"Everyone" cause in f.e. Polish version this group names "Wszyscy" ...
- 15
- Net Framework >> Get LOGON USER name in .NET 2.0I recentlly converted some web services to 2.0. So far everything has worked
great with the exception of one of the functions in an AD service.
the following code:
string sUser = HttpContext.Current.Request.ServerVariables["LOGON_USER"];
Worksk fine if debugging in VS 2005 but when I publish to the server. An
empty string is returned. I have tried to catch an error and does not appear
to be one.
|
|
|