dbTalk Databases Forums  

DTS -- Object doesn't support this property or method

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss DTS -- Object doesn't support this property or method in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Wm. Scott Miller
 
Posts: n/a

Default DTS -- Object doesn't support this property or method - 10-20-2004 , 02:31 PM






PLEASE HELP!!!!!

I have a custom DTS task that I'm trying to manipulate in an ActiveX script
Data Transform task. I am grabbing the object correctly, I can modify the
Description property fine, but when I try to call an extended method or
property I get the above error everytime. I've done this in Delphi and
everything works as expected. In C#, however, I cannot get any of my
extended methods and properties using the same ActiveX script. I can
however see the properties in the Disconnected Edit view, but cannot use
them/modify them in the ActiveX script. I have the class set up as AutoDual
per Microsoft recommendations. Anyone know what I'm missing?

Thanks for any replies,
Scott



Reply With Quote
  #2  
Old   
Wm. Scott Miller
 
Posts: n/a

Default Re: DTS -- Object doesn't support this property or method - 10-21-2004 , 03:37 PM






UPDATE:

Simplified customtask that exhibits the problem:

using System;
using System.Runtime.InteropServices;
using Microsoft.SQLServer.DTSPkg80;
using Microsoft.Win32;
using System.Windows.Forms;

[assembly:ClassInterface(ClassInterfaceType.AutoDua l)]

namespace DTS
{

[Guid("[GUID is created by using GUIDGEN.EXE]"), ComVisible(true)]
[ProgId("DTS.SimpleCustomTask")]
public class SimpleCustomTask : CustomTask
{
private string name;
private string description;
private string message;

public SimpleCustomTask()
{
name = "";
description = "SimpleCustomTask description";
}


public void Execute(object pPackage, object pPackageEvents, object
pPackageLog, ref Microsoft.SQLServer.DTSPkg80.DTSTaskExecResult pTaskResult)
{

//Assume failure at the outset
pTaskResult = DTSTaskExecResult.DTSTaskExecResult_Failure;

try
{

Package2 package = (Package2) pPackage;
PackageEvents packageEvents = (PackageEvents) pPackageEvents;
PackageLog packageLog = (PackageLog) pPackageLog;


MessageBox.Show(message);

}

//First catch COM exceptions, and then all other exceptions
catch(System.Runtime.InteropServices.COMException e)
{

Console.WriteLine(e);
}
catch(System.Exception e)
{

Console.WriteLine(e);
}

//Return success
pTaskResult = DTSTaskExecResult.DTSTaskExecResult_Success;
}

public string Description
{
get { return this.description; }
set { this.description = value; }
}

public string Name
{
get { return name; }
set { this.name = value; }
}

public string Message
{
get { return this.message; }
set { this.message = value; }
}

public Microsoft.SQLServer.DTSPkg80.Properties Properties
{
get { return null; }
}

[System.Runtime.InteropServices.ComVisible(false)]
override public string ToString()
{
return base.ToString();
}


//Registration function for custom task.
[System.Runtime.InteropServices.ComRegisterFunction Attribute()]
static void RegisterServer(Type t)
{
try
{
const string TASK_CACHE = "Software\\Microsoft\\Microsoft SQL
Server\\80\\DTS\\Enumeration\\Tasks";
const string CATID_DTSCustomTask =
"{10020200-EB1C-11CF-AE6E-00AA004A34D5}";
string guid = "{" + t.GUID.ToString() + "}";
guid = guid.ToUpper();

Console.WriteLine("RegisterServer {0}", guid);

RegistryKey root;
RegistryKey rk;
RegistryKey nrk;

// Add COM Category in HKEY_CLASSES_ROOT
root = Registry.ClassesRoot;
rk = root.OpenSubKey("CLSID\\" + guid + "\\Implemented Categories",
true);
nrk = rk.CreateSubKey(CATID_DTSCustomTask);
nrk.Close();
rk.Close();
root.Close();

// Add to DTS Cache in HKEY_CURRENT_USER
root = Registry.CurrentUser;
rk = root.OpenSubKey(TASK_CACHE, true);
nrk = rk.CreateSubKey(guid);
nrk.SetValue("", t.FullName);

nrk.Close();
rk.Close();
root.Close();

SimpleCustomTask ct = new SimpleCustomTask();

root = Registry.ClassesRoot;
rk = root.OpenSubKey("CLSID\\" + guid, true);
rk.SetValue("DTSTaskDescription", ct.description);

nrk.Close();
rk.Close();
root.Close();

}
catch(Exception e)
{
System.Console.WriteLine(e.ToString());
}
}

//Unregistration function for custom task.
[System.Runtime.InteropServices.ComUnregisterFuncti onAttribute()]
static void UnregisterServer(Type t)
{
try
{
const string TASK_CACHE = "Software\\Microsoft\\Microsoft SQL
Server\\80\\DTS\\Enumeration\\Tasks";
string guid = "{" + t.GUID.ToString() + "}";
guid = guid.ToUpper();

Console.WriteLine("UnregisterServer {0}", guid);

RegistryKey root;
RegistryKey rk;

// Delete from DTS Cache in HKEY_CURRENT_USER
root = Registry.CurrentUser;
rk = root.OpenSubKey(TASK_CACHE, true);
rk.DeleteSubKey(guid, false);
rk.Close();
root.Close();
}
catch(Exception e)
{
System.Console.WriteLine(e.ToString());
}
}

}
}

The ActiveX Script fails on the "Message" assigment:

Function Main()
Dim oPackage
Dim oCT
set oPackage = DTSGlobalVariables.Parent
set oCT = oPackage.Tasks("DTSTask_DTS.SimpleCustomTask_1").C ustomTask
oCT.Message = "Hello World"
Main = DTSTransformStat_SkipInsert
End Function

Change the "set oCT" line to "set oCT =
CreateObject("DTS.SimpleCustomTask")" and it works but of course that is
creating the object once for each record which defeats the purpose of having
the task in the first place.

Obviously I'm having a COM interoperability problem. Anyone know how to
fix?

Scott

"Wm. Scott Miller" <Scott.Miller (AT) spam (DOT) killer.wvinsurance.gov> wrote in
message news:eqyHGtttEHA.3156 (AT) TK2MSFTNGP12 (DOT) phx.gbl...
Quote:
PLEASE HELP!!!!!

I have a custom DTS task that I'm trying to manipulate in an ActiveX
script
Data Transform task. I am grabbing the object correctly, I can modify the
Description property fine, but when I try to call an extended method or
property I get the above error everytime. I've done this in Delphi and
everything works as expected. In C#, however, I cannot get any of my
extended methods and properties using the same ActiveX script. I can
however see the properties in the Disconnected Edit view, but cannot use
them/modify them in the ActiveX script. I have the class set up as
AutoDual
per Microsoft recommendations. Anyone know what I'm missing?

Thanks for any replies,
Scott





Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.