I assume you are running this in a report item that is not bound to a dataset - as something like a tablix normally is - which is why you have to specify your dataset name. Because any non-aggregate function you try to apply within an SSRS expression has to be applied to a single value, you need to be more specific than just the field and dataset name; you need to include which row you are applying to function to.
This is normally handled for you either by using an aggregate function - such as sum
or min
or max
- which defaults to 'every row in the specified column' or by being applied in the context of something like a chart or a table, which is running through the rows of the dataset one by one.
As you are doing neither, you need to specify a row. If your dataset only has the one row you can use =Code.GetBarcode(first(Fields!ID.Value,"Dataset"))
which will only return the value in the first row of the dataset. If you have more than one row and you would like to apply this function to each row you will need to add a tablix and enter your expression in the Details
row.