在写自动更新程序中出现的问题

在设计本程序时,出现了两个问题:

第一:下载时,在本机可以实现,但是下载别的FTP时,就会出现产生不了文件的问题。

     解决方法: 原先使用的方法是:先打开一个文件,当接到数据后,把数据写到这个文件里,再接到再写的过程。等数据完成后,再把文件关闭,这时才产生文件。
     现在的方法更改为:先打开一个文件,当接到数据后,把数据写到文件里,并且关闭文件,这时就会产生文件。而等到再接到数据时,再打开这个文件,再写入,再关闭。
     当更改为后一种后,就不再出现这个问题了。 

第二:程序完成后,在本机可以运行,但是在别的机器上时,出现Run Time Error '429'错误。即ActiveX部件不能创建对象。
     
     这个问题是由于Winsock.Ocx控件本身的问题产生的,原因是目标计算机失去了注册信息。


The error occurs because the target computer is missing the license information for the control objects that are used in the application. You might attempt to set the project reference to point to MSWINSCK.ocx, and then generate a deployment package through the use of the Package and Deployment Wizard. This would generate a setup package that contains the correct version of the Winsock control. However, the license key for the control will not be compiled into the application unless an instance of the control is placed on a form. When you try to instantiate the objects at run time, the application has no way to provide the license key, and the code will fail. For example, the following code will run properly at design time, but will fail at run time on computers that do not have Visual Basic installed:

Dim myWinSock As MSWinsockLib.Winsock

Sub Main()
    ' Early binding does not work
    Set myWinSock = New MSWinsockLib.Winsock

    myWinSock.LocalPort = 5432

    myWinSock.Listen

    MsgBox ("Listening!")

    myWinSock.Close
End Sub

通过,下面这种方法,就可以解决这个问题。
Therefore, you must provide an instance of the Winsock control on a form so that Visual Basic can compile the license information into the application. You can make the form hidden if necessary. To do this, set the form's Visible property to "False." You can then prepare for deployment. The following code snippet demonstrates the method:

Dim myWinsock As MSWinsockLib.Winsock

Sub Main()
    ' Form1 is hidden
    Set myWinsock = Form1.myWinsock

    myWinsock.LocalPort = 5432

    myWinsock.Listen

    MsgBox ("Listening!")

    myWinsock.Close
End Sub
posted @ 2005-05-18 17:07  空中的风月  阅读(1040)  评论(1编辑  收藏  举报