我試圖從COM(jscript)訪問.Net庫(The Image Resizer)。COM - > .NET - 無法訪問重載的方法
我已經嘗試過IDispatch和類接口生成,以及有問題的類上的[ClassInterface(ClassInterfaceType.AutoDual)]。
有一個與3個重載的方法:
Bitmap Build(object, ResizeSettings settings)
void Build(object source, object dest, string settings)
void Build(object source, object dest, ResizeSettings settings)
調用
Build("file",s); //works
以下二者生成(JScript運行時錯誤)
Build("file","file", s)
Build("file","file","settings
「參數或無效的屬性賦值錯誤數」
我找不到任何重載不應該通過互操作的原因,especi當arg計數不同時盟友。 我錯過了什麼嗎?
更新:這裏是方法定義的完整代碼。第二次過載不可訪問。這不僅僅是這些方法 - 在每個重載方法中,我似乎只能訪問第一個重載。這是一個沒有記錄的COM錯誤/設計缺陷嗎?
/// <summary>
/// Provides methods for generating resized images, and for reading and writing them to disk.
/// Use ImageBuilder.Current to get the current instance (as configured in the application configuration), or use ImageBuilder.Current.Create() to control which extensions are used.
/// </summary>
public class ImageBuilder : AbstractImageProcessor, IQuerystringPlugin
{
/// <summary>
/// Resizes and processes the specified source image and returns a bitmap of the result.
/// This method assumes that transparency will be supported in the final output format, and therefore does not apply a matte color. Use &bgcolor to specify a background color
/// if you use this method with a non-transparent format such as Jpeg.
/// </summary>
/// <param name="source">May be an instance of string (a physical path), VirtualFile, IVirtualBitmapFile, HttpPostedFile, Bitmap, Image, or Stream.</param>
/// <param name="settings">Resizing and processing command to apply to the.</param>
public virtual Bitmap Build(object source, ResizeSettings settings) {
BitmapHolder bh = new BitmapHolder();
Build(source, bh, settings);
return bh.bitmap;
}
/// <summary>
/// Resizes and processes the specified source image and stores the encoded result in the specified destination.
/// </summary>
/// <param name="source">May be an instance of string (a physical path or app-relative virtual path), VirtualFile, IVirtualBitmapFile, HttpPostedFile, Bitmap, Image, or Stream. app-relative virtual paths will use the VirtualPathProvider system</param>
/// <param name="dest">May be a physical path (string), or a Stream instance. Does not have to be seekable.</param>
/// <param name="settings">Resizing and processing command to apply to the.</param>
public virtual void Build(object source, object dest, ResizeSettings settings) {
ResizeSettings s = new ResizeSettings(settings);
我覺得你的COM組件的代碼(或至少界面)在這裏更重要......你可以發佈嗎? – fretje 2011-05-17 13:53:31
組件是.NET,調用者是COM。我會添加更多的代碼。 – 2011-05-17 14:00:58
我不明白。 jscript不是COM。它可以很容易地調用COM組件。如果你希望.NET組件可以作爲COM組件訪問,你必須爲你的.NET組件添加代碼(比如'ClassInterface(ClassInterfaceType.AutoDual)'你在談論你的問題)。這使.NET組件成爲COM服務器。 – fretje 2011-05-17 14:04:59