Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

"TypeError: No method matches given arguments" error for a virtual method with a template parameter #1522

Closed
Assignees
filmor
Labels
Milestone
@rayrapetyan

Description

@rayrapetyan

Environment

Details

Trying to re-implement example fromhere using Python.

Everything works fine except this line of code:

slideMasterPart1.AddPart(slideLayoutPart1,"rId1");

There are two definitions ofAddPart:

publicvirtualTAddPart<T>(Tpart)whereT:OpenXmlPartpublicvirtualTAddPart<T>(Tpart,stringid)whereT:OpenXmlPart

slideMasterPart1.AddPart.Overloads output:

T AddPart[T](T)T AddPart[T](T, System.String)

What works:

slideMasterPart1.AddPart(slideLayoutPart1)slideMasterPart1.AddPart[SlideLayoutPart](slideLayoutPart1)

What doesn't work:

slideMasterPart1.AddPart(slideLayoutPart1,"rId1")slideMasterPart1.AddPart(slideLayoutPart1,System.String("rId1"))slideMasterPart1.AddPart[SlideLayoutPart](slideLayoutPart1,"rId1")

Error:

Python.Runtime.PythonException: DocumentFormat.OpenXml.Packaging.SlideLayoutPart value cannot be converted to TThe above exception was the direct cause of the following exception:System.ArgumentException: DocumentFormat.OpenXml.Packaging.SlideLayoutPart value cannot be converted to T in method T AddPart[T](T, System.String) ---> Python.Runtime.PythonException: DocumentFormat.OpenXml.Packaging.SlideLayoutPart value cannot be converted to T   --- End of inner exception stack trace ---The above exception was the direct cause of the following exception:System.AggregateException: One or more errors occurred. (DocumentFormat.OpenXml.Packaging.SlideLayoutPart value cannot be converted to T in method T AddPart[T](T, System.String)) ---> System.ArgumentException: DocumentFormat.OpenXml.Packaging.SlideLayoutPart value cannot be converted to T in method T AddPart[T](T, System.String) ---> Python.Runtime.PythonException: DocumentFormat.OpenXml.Packaging.SlideLayoutPart value cannot be converted to T   --- End of inner exception stack trace ---   --- End of inner exception stack trace ------> (Inner Exception #0) System.ArgumentException: DocumentFormat.OpenXml.Packaging.SlideLayoutPart value cannot be converted to T in method T AddPart[T](T, System.String) ---> Python.Runtime.PythonException: DocumentFormat.OpenXml.Packaging.SlideLayoutPart value cannot be converted to T   --- End of inner exception stack trace ---<---The above exception was the direct cause of the following exception:...slideMasterPart1.AddPart(slideLayoutPart1, "rId1");TypeError: No method matches given arguments for AddPart: (<class 'DocumentFormat.OpenXml.Packaging.SlideLayoutPart'>, <class 'str'>)

mcve:

importclrclr.AddReference('DocumentFormat.OpenXml')fromDocumentFormat.OpenXml.Packagingimport (SlideLayoutPart,SlideMasterPart,)slideLayoutPart1:SlideLayoutPart=SlideLayoutPart()slideMasterPart1:SlideMasterPart=SlideMasterPart()slideMasterPart1.AddPart(slideLayoutPart1)# this works OKslideMasterPart1.AddPart(slideLayoutPart1,"rId1")# this raises a runtime exception

So it's only when the second (string) parameter is provided, the first can't be converted. Looks like a pythonnet issue.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp