我有一个我在4.5中构建的.NET应用程序,它引用了一堆用4.5构建的库,它们本身引用了4.5等.我正在尝试分发应用程序的用户组正在使用运行可执行文件的问题,因为它们已安装4.0; 特别是,他们遇到了MissingMethodException:
Method not found: 'System.Type System.Runtime.InteropServices.Marshal.GetTypeFromCLSID(System.Guid)'.
Run Code Online (Sandbox Code Playgroud)
因为我们可能无法将每个用户升级到4.5(因为他们都没有在他们的计算机上拥有管理员权限,这需要为每个用户单独升级请求),我正在寻找一种简单的方法来重建项目为4.0 .这似乎要求我在4.0中重建每个库及其引用的库; 有没有比通过逐个浏览每个库并构建4.0版本更简单的方法?我想也许就像"重建目标框架中所有引用的库"之类的一键式选项或类似的东西.
我正在尝试使用SSH.NET通过SFTP上传文件. SFTPClient.Connect()抛出SshConnectionException,并显示消息"Bad packet length 1302334341".这是我的代码:
static void Main()
{
try
{
SftpClient sftp = new SftpClient(server, 22, userID, password);
sftp.Connect();
}
catch(Exception e)
{
Console.WriteLine(e.Message);
}
}
Run Code Online (Sandbox Code Playgroud)
我在另一个讨论中看到,这可能与加密有关.我正在使用AES,而且我有一个主机密钥.不过,我不明白如何输入加密.基于那个讨论,我正在玩这个:
ConnectionInfo connectionInfo = new PasswordConnectionInfo(server, 22, userID, password);
connectionInfo.Encryptions.Clear();
connectionInfo.Encryptions.Add("aes","ssh-rsa 2048 11:22:34:d4:56:d6:78:90:01:22:6b:46:34:54:55:8a")
Run Code Online (Sandbox Code Playgroud)
我知道这不是传递给Encryptions.Add()的正确参数集,但我使用这个库时有点迷失; 你能帮我弄清楚如何正确设置加密(假设这是问题)?
我正在尝试获取所有当前打开的Excel工作簿的列表,以便用户可以选择从其中一个中获取一些数据。
我尝试了这个:
List<string> excelList = new List<string>();
Process[] processList = Process.GetProcessesByName("excel");
foreach (Process p in processList)
{
excelList.Add(p.MainWindowTitle);
Console.WriteLine(p.MainWindowTitle);
}
Run Code Online (Sandbox Code Playgroud)
但这只会获得第一个打开的Excel实例和最近打开的实例,因此在这两个实例之间打开的任何工作簿都不会在列表中。
我也开始探索此SO问题的答案中博客链接中描述的解决方案,并尝试使用博客条目中建议的代码访问“运行对象表”:
IBindCtx bc;
IRunningObjectTable rot;
CreateBindCtx(0, out bc);
bc.GetRunningObjectTable(out rot);
Run Code Online (Sandbox Code Playgroud)
这里的问题是,CreateBindCtx实际上接受a UCOMIBindCTX代替IBindCTX,但是UCOMIBindCTX对于MSDN已经过时了。
有没有一种更简单的方法可以执行我想做的事情:获取Workbook与所有打开的Excel书籍相对应的对象列表?
我正在尝试获得3个表的UNION,每个表有97个字段.我尝试过以下方法:
select * from table1
union all
select * from table2
union all
select * from table3
Run Code Online (Sandbox Code Playgroud)
这给了我一个错误信息:
Too many fields defined.
Run Code Online (Sandbox Code Playgroud)
我还尝试从第一个表中明确选择所有字段名称(为简洁起见,添加了省略号):
select [field1],[field2]...[field97] from table1
union all
select * from table2
union all
select * from table3
Run Code Online (Sandbox Code Playgroud)
当我只有这样的UNION两个表时,它工作正常:
select * from table1
union all
select * from table2
Run Code Online (Sandbox Code Playgroud)
作为此查询的结果,我最终不应该有超过97个字段; 两桌UNION只有97.所以我为什么Too many fields要用3张牌?
编辑:正如RichardTheKiwi在下面所说,Access正在总结UNION链中每个SELECT查询的字段数,这意味着我的3个表超过了255个字段的最大值.所以相反,我需要像这样编写查询:
select * from table1
union all
select * from
(select * from table2
union all
select * from table3)
Run Code Online (Sandbox Code Playgroud)
哪个工作正常.
正如在这个问题中所描述的那样,我正在研究一种方法,该方法从一个List<FileInfo>不存在于另一个中的元素返回元素List<FileInfo>.我已经实现了Nawfal的解决方案如下:
public List<FileInfo> SourceNotInDest(List<FileInfo> SourceFiles, List<FileInfo> DestFiles)
{
var notInDest = SourceFiles.Where(c => !DestFiles.Any(p => p.Name == c.Name)).ToList();
return notInDest;
}
Run Code Online (Sandbox Code Playgroud)
我为SourceFiles设置的数据是:
u:\folder1\a.txt
u:\folder1\b.txt
u:\folder1\c.txt
u:\folder1\d.txt
Run Code Online (Sandbox Code Playgroud)
DestFiles是:
u:\folder2\a.txt
u:\folder2\b.txt
u:\folder2\c.txt
Run Code Online (Sandbox Code Playgroud)
当我单步执行代码并检查列表的值时,这似乎返回预期的结果.但单元测试失败,代码如下:
public void SourceNotInDestTest()
{
//arrange
FileListComparer flc = new FileListComparer(); //class that has the list compare method
FolderReader fr = new FolderReader(); //class for getting FileInfo from folder
List<FileInfo> expectedResult = new List<FileInfo>();
expectedResult.Add(new FileInfo(@"U:\folder1\d.txt"));
List<FileInfo> SourceFiles = fr.fileList(@"U:\folder1"); //gets the FileInfo for …Run Code Online (Sandbox Code Playgroud) 我正在开发一个项目,其中数据集存储在Sharepoint服务器上的文件夹中的数千个Excel工作簿(当前约为14000个)中,每个工作簿都会定期修改以反映该工作簿中数据子集的更改.我知道这不是存储和更新这些数据的好方法,但情况就是这样.
我必须执行各种查询,涉及从文件夹中的所有工作簿中提取一个或多个字段的内容.我一直在通过迭代这组工作簿来做到这一点,如下所示:
Function getData() As Workbook
Dim resultBk As Workbook
Dim fldr As Folder
Dim fso As New FileSystemObject
Dim fileObj As File
Dim filePath As String
Dim queryBk As Workbook
'create a workbook for storing the query results
Set resultBk = Workbooks.Add(resultBkTemplatePath)
'get the folder with all the workbooks to be queried
Set fldr = fso.GetFolder(sharepointFolderPath)
For Each fileObj In fldr.Files
'try opening each of the workbooks
Set queryBk = Workbooks.Open(fileObj.Path, ReadOnly:=True)
'get data from queryBk and add it …Run Code Online (Sandbox Code Playgroud) 我有一个Twilio试用帐户,我一直在测试一个用于接收短信的网络应用程序.我已经为入站短信分配了一个URL,并且一直运行良好.到目前为止,我没有遇到任何限制我可以收到多少短信,多快或类似的东西.我在Twilio网站上也没有找到关于此的任何内容.
我的试用帐户收到短信的限制是多少?我不需要向SMS发件人发送回复,所以我不担心发送短信的费用,或者发送短信附加的"发送的Twilio".
考虑以下VBA功能:
Function castAndAdd(inputValue As Variant) As Variant
If IsNumeric(inputValue) Then
castAndAdd = CDbl(inputValue) + 4
Else
castAndAdd = inputValue
End If
End Function
Run Code Online (Sandbox Code Playgroud)
从即时窗口调用它给出了这个输出:
?castAndAdd("5,7")
61
?castAndAdd("5, 7")
5, 7
Run Code Online (Sandbox Code Playgroud)
单步执行"5,7"调用,我发现IsNumeric("5,7")返回true.我想也许它会给出这个结果,因为在欧洲,逗号用作小数分隔符; 这个结果很奇怪,因为我在美国,所以我的语言环境应该确定Excel只将句点识别为小数点分隔符,对吧?
即使我们搁置欧洲/美国问题,更大的问题是CDbl("5,7")返回57,因此CDbl("5,7") + 4如果逗号是小数分隔符,则返回61而不是9.7.这是一个错误,还是我只是不明白如何使用CDbl()?
使用 VBA,我试图使用正则表达式从没有扩展名的 UNC 路径中捕获文件名 - 仅查看 .TIF 文件。
到目前为止,这就是我所拥有的:
Function findTIFname(filestr As String) As String
Dim re As RegExp
Dim output As String
Dim matches As MatchCollection
Set re = New RegExp
re.pattern = "[^\\]+(?:[.]tif)$"
Set matches = re.Execute(filestr)
If matches.Count > 0 Then
output = matches(0).Value
Else
output = ""
End If
findTIFname = output
End Function
Run Code Online (Sandbox Code Playgroud)
但是当我按如下方式运行函数时:
msgbox findTIFname("\\abc\def\ghi\jkl\41e07.tif")
Run Code Online (Sandbox Code Playgroud)
我得到以下输出:
41e07.tif
Run Code Online (Sandbox Code Playgroud)
我认为“(?:xxx)”是非捕获组的正则表达式语法;我究竟做错了什么?
我想从Excel范围获取一个字符串列表,其中数据可以是混合类型(字符串,双精度等).我试过用这个:
List<string> rangeToList(Excel.Range inputRng)
{
object[,] cellValues = (object[,])inputRng.Value2;
List<string> lst = cellValues.Cast<string>().ToList();
return lst;
}
Run Code Online (Sandbox Code Playgroud)
但该行Cast<string>返回此错误:
Unable to cast object of type 'System.Double' to type 'System.String'
Run Code Online (Sandbox Code Playgroud)
如何将此对象数组转换为我想要的列表?